@lookit/record 0.0.3

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.
@@ -0,0 +1,353 @@
1
+ import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
2
+ declare const info: {
3
+ readonly name: "consent-video";
4
+ readonly version: string;
5
+ readonly parameters: {
6
+ readonly template: {
7
+ readonly type: ParameterType.STRING;
8
+ readonly default: "consent_005";
9
+ };
10
+ readonly locale: {
11
+ readonly type: ParameterType.STRING;
12
+ readonly default: "en-us";
13
+ };
14
+ readonly additional_video_privacy_statement: {
15
+ readonly type: ParameterType.STRING;
16
+ readonly default: "";
17
+ };
18
+ readonly datause: {
19
+ readonly type: ParameterType.STRING;
20
+ readonly default: "";
21
+ };
22
+ readonly gdpr: {
23
+ readonly type: ParameterType.BOOL;
24
+ readonly default: false;
25
+ };
26
+ readonly gdpr_personal_data: {
27
+ readonly type: ParameterType.STRING;
28
+ readonly default: "";
29
+ };
30
+ readonly gdpr_sensitive_data: {
31
+ readonly type: ParameterType.STRING;
32
+ readonly default: "";
33
+ };
34
+ readonly PIName: {
35
+ readonly type: ParameterType.STRING;
36
+ readonly default: "";
37
+ };
38
+ readonly include_databrary: {
39
+ readonly type: ParameterType.BOOL;
40
+ readonly default: false;
41
+ };
42
+ readonly institution: {
43
+ readonly type: ParameterType.STRING;
44
+ readonly default: "";
45
+ };
46
+ readonly PIContact: {
47
+ readonly type: ParameterType.STRING;
48
+ readonly default: "";
49
+ };
50
+ readonly payment: {
51
+ readonly type: ParameterType.STRING;
52
+ readonly default: "";
53
+ };
54
+ readonly private_level_only: {
55
+ readonly type: ParameterType.BOOL;
56
+ readonly default: false;
57
+ };
58
+ readonly procedures: {
59
+ readonly type: ParameterType.STRING;
60
+ readonly default: "";
61
+ };
62
+ readonly purpose: {
63
+ readonly type: ParameterType.STRING;
64
+ readonly default: "";
65
+ };
66
+ readonly research_rights_statement: {
67
+ readonly type: ParameterType.STRING;
68
+ readonly default: "";
69
+ };
70
+ readonly risk_statement: {
71
+ readonly type: ParameterType.STRING;
72
+ readonly default: "";
73
+ };
74
+ readonly voluntary_participation: {
75
+ readonly type: ParameterType.STRING;
76
+ readonly default: "";
77
+ };
78
+ readonly purpose_header: {
79
+ readonly type: ParameterType.STRING;
80
+ readonly default: "";
81
+ };
82
+ readonly procedures_header: {
83
+ readonly type: ParameterType.STRING;
84
+ readonly default: "";
85
+ };
86
+ readonly participation_header: {
87
+ readonly type: ParameterType.STRING;
88
+ readonly default: "";
89
+ };
90
+ readonly benefits_header: {
91
+ readonly type: ParameterType.STRING;
92
+ readonly default: "";
93
+ };
94
+ readonly risk_header: {
95
+ readonly type: ParameterType.STRING;
96
+ readonly default: "";
97
+ };
98
+ readonly summary_statement: {
99
+ readonly type: ParameterType.STRING;
100
+ readonly default: "";
101
+ };
102
+ readonly additional_segments: {
103
+ readonly type: ParameterType.COMPLEX;
104
+ readonly array: true;
105
+ readonly nested: {
106
+ readonly title: {
107
+ readonly type: ParameterType.STRING;
108
+ readonly default: "";
109
+ };
110
+ };
111
+ readonly text: {
112
+ readonly type: ParameterType.STRING;
113
+ readonly default: "";
114
+ };
115
+ };
116
+ readonly prompt_all_adults: {
117
+ readonly type: ParameterType.BOOL;
118
+ readonly default: false;
119
+ };
120
+ readonly prompt_only_adults: {
121
+ readonly type: ParameterType.BOOL;
122
+ readonly default: false;
123
+ };
124
+ readonly consent_statement_text: {
125
+ readonly type: ParameterType.STRING;
126
+ readonly default: "";
127
+ };
128
+ readonly omit_injury_phrase: {
129
+ readonly type: ParameterType.BOOL;
130
+ readonly default: false;
131
+ };
132
+ };
133
+ };
134
+ type Info = typeof info;
135
+ /** The video consent plugin. */
136
+ export declare class VideoConsentPlugin implements JsPsychPlugin<Info> {
137
+ private readonly jsPsych;
138
+ static readonly info: {
139
+ readonly name: "consent-video";
140
+ readonly version: string;
141
+ readonly parameters: {
142
+ readonly template: {
143
+ readonly type: ParameterType.STRING;
144
+ readonly default: "consent_005";
145
+ };
146
+ readonly locale: {
147
+ readonly type: ParameterType.STRING;
148
+ readonly default: "en-us";
149
+ };
150
+ readonly additional_video_privacy_statement: {
151
+ readonly type: ParameterType.STRING;
152
+ readonly default: "";
153
+ };
154
+ readonly datause: {
155
+ readonly type: ParameterType.STRING;
156
+ readonly default: "";
157
+ };
158
+ readonly gdpr: {
159
+ readonly type: ParameterType.BOOL;
160
+ readonly default: false;
161
+ };
162
+ readonly gdpr_personal_data: {
163
+ readonly type: ParameterType.STRING;
164
+ readonly default: "";
165
+ };
166
+ readonly gdpr_sensitive_data: {
167
+ readonly type: ParameterType.STRING;
168
+ readonly default: "";
169
+ };
170
+ readonly PIName: {
171
+ readonly type: ParameterType.STRING;
172
+ readonly default: "";
173
+ };
174
+ readonly include_databrary: {
175
+ readonly type: ParameterType.BOOL;
176
+ readonly default: false;
177
+ };
178
+ readonly institution: {
179
+ readonly type: ParameterType.STRING;
180
+ readonly default: "";
181
+ };
182
+ readonly PIContact: {
183
+ readonly type: ParameterType.STRING;
184
+ readonly default: "";
185
+ };
186
+ readonly payment: {
187
+ readonly type: ParameterType.STRING;
188
+ readonly default: "";
189
+ };
190
+ readonly private_level_only: {
191
+ readonly type: ParameterType.BOOL;
192
+ readonly default: false;
193
+ };
194
+ readonly procedures: {
195
+ readonly type: ParameterType.STRING;
196
+ readonly default: "";
197
+ };
198
+ readonly purpose: {
199
+ readonly type: ParameterType.STRING;
200
+ readonly default: "";
201
+ };
202
+ readonly research_rights_statement: {
203
+ readonly type: ParameterType.STRING;
204
+ readonly default: "";
205
+ };
206
+ readonly risk_statement: {
207
+ readonly type: ParameterType.STRING;
208
+ readonly default: "";
209
+ };
210
+ readonly voluntary_participation: {
211
+ readonly type: ParameterType.STRING;
212
+ readonly default: "";
213
+ };
214
+ readonly purpose_header: {
215
+ readonly type: ParameterType.STRING;
216
+ readonly default: "";
217
+ };
218
+ readonly procedures_header: {
219
+ readonly type: ParameterType.STRING;
220
+ readonly default: "";
221
+ };
222
+ readonly participation_header: {
223
+ readonly type: ParameterType.STRING;
224
+ readonly default: "";
225
+ };
226
+ readonly benefits_header: {
227
+ readonly type: ParameterType.STRING;
228
+ readonly default: "";
229
+ };
230
+ readonly risk_header: {
231
+ readonly type: ParameterType.STRING;
232
+ readonly default: "";
233
+ };
234
+ readonly summary_statement: {
235
+ readonly type: ParameterType.STRING;
236
+ readonly default: "";
237
+ };
238
+ readonly additional_segments: {
239
+ readonly type: ParameterType.COMPLEX;
240
+ readonly array: true;
241
+ readonly nested: {
242
+ readonly title: {
243
+ readonly type: ParameterType.STRING;
244
+ readonly default: "";
245
+ };
246
+ };
247
+ readonly text: {
248
+ readonly type: ParameterType.STRING;
249
+ readonly default: "";
250
+ };
251
+ };
252
+ readonly prompt_all_adults: {
253
+ readonly type: ParameterType.BOOL;
254
+ readonly default: false;
255
+ };
256
+ readonly prompt_only_adults: {
257
+ readonly type: ParameterType.BOOL;
258
+ readonly default: false;
259
+ };
260
+ readonly consent_statement_text: {
261
+ readonly type: ParameterType.STRING;
262
+ readonly default: "";
263
+ };
264
+ readonly omit_injury_phrase: {
265
+ readonly type: ParameterType.BOOL;
266
+ readonly default: false;
267
+ };
268
+ };
269
+ };
270
+ private readonly recorder;
271
+ private readonly video_container_id;
272
+ /**
273
+ * Instantiate video consent plugin.
274
+ *
275
+ * @param jsPsych - JsPsych object
276
+ */
277
+ constructor(jsPsych: JsPsych);
278
+ /**
279
+ * Create/Show trial view.
280
+ *
281
+ * @param display - HTML element for experiment.
282
+ * @param trial - Trial data including user supplied parameters.
283
+ */
284
+ trial(display: HTMLElement, trial: TrialType<Info>): void;
285
+ /**
286
+ * Retrieve video container element.
287
+ *
288
+ * @param display - HTML element for experiment.
289
+ * @returns Video container
290
+ */
291
+ private getVideoContainer;
292
+ /**
293
+ * Add webcam feed to HTML.
294
+ *
295
+ * @param display - HTML element for experiment.
296
+ */
297
+ private recordFeed;
298
+ /**
299
+ * Playback Feed
300
+ *
301
+ * @param display - JsPsych display HTML element.
302
+ */
303
+ private playbackFeed;
304
+ /**
305
+ * Put back the webcam feed once the video recording has ended. This is used
306
+ * with the "ended" Event.
307
+ *
308
+ * @param display - JsPsych display HTML element.
309
+ * @returns Event function
310
+ */
311
+ private onEnded;
312
+ /**
313
+ * Retrieve button element from DOM.
314
+ *
315
+ * @param display - HTML element for experiment.
316
+ * @param id - Element id
317
+ * @returns Button element
318
+ */
319
+ private getButton;
320
+ /**
321
+ * Select and return the image element.
322
+ *
323
+ * @param display - HTML element for experiment.
324
+ * @param id - ID string of Image element
325
+ * @returns Image Element
326
+ */
327
+ private getImg;
328
+ /**
329
+ * Add record button to HTML.
330
+ *
331
+ * @param display - HTML element for experiment.
332
+ */
333
+ private recordButton;
334
+ /**
335
+ * Set up play button to playback last recorded video.
336
+ *
337
+ * @param display - HTML element for experiment.
338
+ */
339
+ private playButton;
340
+ /**
341
+ * Add stop button to HTML.
342
+ *
343
+ * @param display - HTML element for experiment.
344
+ */
345
+ private stopButton;
346
+ /**
347
+ * Add next button to HTML.
348
+ *
349
+ * @param display - HTML element for experiment.
350
+ */
351
+ private nextButton;
352
+ }
353
+ export {};
@@ -0,0 +1,158 @@
1
+ /** Error thrown when recorder is null. */
2
+ export declare class RecorderInitializeError extends Error {
3
+ /**
4
+ * When there isn't a recorder, provide the user with an explanation of what
5
+ * they could do to resolve the issue.
6
+ */
7
+ constructor();
8
+ }
9
+ /** Error thrown when stream is inactive and recorder is started. */
10
+ export declare class StreamInactiveInitializeError extends Error {
11
+ /**
12
+ * Error check on initialize. Attempting to validate recorder is ready to
13
+ * start recording.
14
+ */
15
+ constructor();
16
+ }
17
+ /** Error thrown when stream data is available and recorder is started. */
18
+ export declare class StreamDataInitializeError extends Error {
19
+ /**
20
+ * Error check on recorder initialize. Attempt to validate recorder data array
21
+ * is empty and ready to start recording.
22
+ */
23
+ constructor();
24
+ }
25
+ /**
26
+ * Error thrown when trying to stop an active session recording that cannot be
27
+ * found.
28
+ */
29
+ export declare class NoSessionRecordingError extends Error {
30
+ /**
31
+ * When trying to stop a recording that isn't found, provide the user with an
32
+ * explanation of what they could do to resolve the issue.
33
+ */
34
+ constructor();
35
+ }
36
+ /**
37
+ * Error thrown when trying to trying to start a recording while another is
38
+ * already active.
39
+ */
40
+ export declare class ExistingRecordingError extends Error {
41
+ /**
42
+ * When trying to start a recording but there is already an active recording
43
+ * in progress, provide the user with an explanation of what they could do to
44
+ * resolve the issue.
45
+ */
46
+ constructor();
47
+ }
48
+ /**
49
+ * Error thrown when trying to to stop the recorder and the stop promise doesn't
50
+ * exist.
51
+ */
52
+ export declare class NoStopPromiseError extends Error {
53
+ /**
54
+ * When attempting to stop a recording but there's no stop promise to ensure
55
+ * the stop has completed.
56
+ */
57
+ constructor();
58
+ }
59
+ /**
60
+ * Error thrown when attempting an action that relies on an input stream, such
61
+ * as the mic volume check, but no such stream is found.
62
+ */
63
+ export declare class NoStreamError extends Error {
64
+ /**
65
+ * When attempting an action that requires an input stream, such as the mic
66
+ * check, but no stream is found.
67
+ */
68
+ constructor();
69
+ }
70
+ /**
71
+ * Error thrown if there's a problem setting up the microphone input level
72
+ * check.
73
+ */
74
+ export declare class MicCheckError extends Error {
75
+ /**
76
+ * Occurs if there's a problem setting up the mic check, including setting up
77
+ * the audio context and stream source, loading the audio worklet processor
78
+ * script, setting up the port message event handler, and resolving the
79
+ * promise chain via message events passed to onMicActivityLevel.
80
+ *
81
+ * @param err - Error passed into this error that is thrown in the catch
82
+ * block, if any. Errors passed to catch blocks must have type unknown.
83
+ */
84
+ constructor(err: unknown);
85
+ }
86
+ /**
87
+ * Error thrown when attempting to access S3 object and it's, unknowingly,
88
+ * undefined.
89
+ */
90
+ export declare class S3UndefinedError extends Error {
91
+ /**
92
+ * Provide feed back when recorder attempts to use S3 object and it's
93
+ * undefined.
94
+ */
95
+ constructor();
96
+ }
97
+ /**
98
+ * Error thrown when attempting to reset recorder, but its stream is still
99
+ * active.
100
+ */
101
+ export declare class StreamActiveOnResetError extends Error {
102
+ /**
103
+ * This error will be thrown when developer attempts to reset recorder while
104
+ * active.
105
+ */
106
+ constructor();
107
+ }
108
+ /** Error thrown when attempting to select webcam element and it's not found. */
109
+ export declare class NoWebCamElementError extends Error {
110
+ /**
111
+ * Error thrown when attempting to retrieve webcam element and it's not in the
112
+ * DOM.
113
+ */
114
+ constructor();
115
+ }
116
+ /**
117
+ * Error thrown when attempting to create playback/download url and data array
118
+ * is empty.
119
+ */
120
+ export declare class CreateURLError extends Error {
121
+ /**
122
+ * Throw this error when data array is empty and url still needs to be
123
+ * created. Sometimes this means the "reset()" method was called too early.
124
+ */
125
+ constructor();
126
+ }
127
+ /** Error thrown when video container couldn't be found. */
128
+ export declare class VideoContainerNotFoundError extends Error {
129
+ /** No video container found. */
130
+ constructor();
131
+ }
132
+ /** Error thrown when button not found. */
133
+ export declare class ButtonNotFoundError extends Error {
134
+ /**
135
+ * Button couldn't be found by ID field.
136
+ *
137
+ * @param id - HTML ID parameter.
138
+ */
139
+ constructor(id: string);
140
+ }
141
+ /** Throw Error when image couldn't be found. */
142
+ export declare class ImageNotFoundError extends Error {
143
+ /**
144
+ * Error when image couldn't be found by ID field.
145
+ *
146
+ * @param id - HTML ID parameter
147
+ */
148
+ constructor(id: string);
149
+ }
150
+ /** Error throw what specified language isn't found */
151
+ export declare class TranslationNotFoundError extends Error {
152
+ /**
153
+ * This will be thrown when attempting to init i18n
154
+ *
155
+ * @param baseName - Language a2code with region
156
+ */
157
+ constructor(baseName: string);
158
+ }