@lookit/record 2.0.0 → 3.0.1

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.
@@ -1,370 +0,0 @@
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-template-5";
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: undefined;
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: undefined;
45
- };
46
- readonly PIContact: {
47
- readonly type: ParameterType.STRING;
48
- readonly default: undefined;
49
- };
50
- readonly payment: {
51
- readonly type: ParameterType.STRING;
52
- readonly default: undefined;
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: undefined;
61
- };
62
- readonly purpose: {
63
- readonly type: ParameterType.STRING;
64
- readonly default: undefined;
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 default: readonly [];
106
- readonly nested: {
107
- readonly title: {
108
- readonly type: ParameterType.STRING;
109
- readonly default: "";
110
- };
111
- readonly text: {
112
- readonly type: ParameterType.STRING;
113
- readonly default: "";
114
- };
115
- };
116
- };
117
- readonly prompt_all_adults: {
118
- readonly type: ParameterType.BOOL;
119
- readonly default: false;
120
- };
121
- readonly prompt_only_adults: {
122
- readonly type: ParameterType.BOOL;
123
- readonly default: false;
124
- };
125
- readonly consent_statement_text: {
126
- readonly type: ParameterType.STRING;
127
- readonly default: "";
128
- };
129
- readonly omit_injury_phrase: {
130
- readonly type: ParameterType.BOOL;
131
- readonly default: false;
132
- };
133
- };
134
- };
135
- type Info = typeof info;
136
- /** The video consent plugin. */
137
- export declare class VideoConsentPlugin implements JsPsychPlugin<Info> {
138
- private readonly jsPsych;
139
- static readonly info: {
140
- readonly name: "consent-video";
141
- readonly version: string;
142
- readonly parameters: {
143
- readonly template: {
144
- readonly type: ParameterType.STRING;
145
- readonly default: "consent-template-5";
146
- };
147
- readonly locale: {
148
- readonly type: ParameterType.STRING;
149
- readonly default: "en-us";
150
- };
151
- readonly additional_video_privacy_statement: {
152
- readonly type: ParameterType.STRING;
153
- readonly default: "";
154
- };
155
- readonly datause: {
156
- readonly type: ParameterType.STRING;
157
- readonly default: "";
158
- };
159
- readonly gdpr: {
160
- readonly type: ParameterType.BOOL;
161
- readonly default: false;
162
- };
163
- readonly gdpr_personal_data: {
164
- readonly type: ParameterType.STRING;
165
- readonly default: "";
166
- };
167
- readonly gdpr_sensitive_data: {
168
- readonly type: ParameterType.STRING;
169
- readonly default: "";
170
- };
171
- readonly PIName: {
172
- readonly type: ParameterType.STRING;
173
- readonly default: undefined;
174
- };
175
- readonly include_databrary: {
176
- readonly type: ParameterType.BOOL;
177
- readonly default: false;
178
- };
179
- readonly institution: {
180
- readonly type: ParameterType.STRING;
181
- readonly default: undefined;
182
- };
183
- readonly PIContact: {
184
- readonly type: ParameterType.STRING;
185
- readonly default: undefined;
186
- };
187
- readonly payment: {
188
- readonly type: ParameterType.STRING;
189
- readonly default: undefined;
190
- };
191
- readonly private_level_only: {
192
- readonly type: ParameterType.BOOL;
193
- readonly default: false;
194
- };
195
- readonly procedures: {
196
- readonly type: ParameterType.STRING;
197
- readonly default: undefined;
198
- };
199
- readonly purpose: {
200
- readonly type: ParameterType.STRING;
201
- readonly default: undefined;
202
- };
203
- readonly research_rights_statement: {
204
- readonly type: ParameterType.STRING;
205
- readonly default: "";
206
- };
207
- readonly risk_statement: {
208
- readonly type: ParameterType.STRING;
209
- readonly default: "";
210
- };
211
- readonly voluntary_participation: {
212
- readonly type: ParameterType.STRING;
213
- readonly default: "";
214
- };
215
- readonly purpose_header: {
216
- readonly type: ParameterType.STRING;
217
- readonly default: "";
218
- };
219
- readonly procedures_header: {
220
- readonly type: ParameterType.STRING;
221
- readonly default: "";
222
- };
223
- readonly participation_header: {
224
- readonly type: ParameterType.STRING;
225
- readonly default: "";
226
- };
227
- readonly benefits_header: {
228
- readonly type: ParameterType.STRING;
229
- readonly default: "";
230
- };
231
- readonly risk_header: {
232
- readonly type: ParameterType.STRING;
233
- readonly default: "";
234
- };
235
- readonly summary_statement: {
236
- readonly type: ParameterType.STRING;
237
- readonly default: "";
238
- };
239
- readonly additional_segments: {
240
- readonly type: ParameterType.COMPLEX;
241
- readonly array: true;
242
- readonly default: readonly [];
243
- readonly nested: {
244
- readonly title: {
245
- readonly type: ParameterType.STRING;
246
- readonly default: "";
247
- };
248
- readonly text: {
249
- readonly type: ParameterType.STRING;
250
- readonly default: "";
251
- };
252
- };
253
- };
254
- readonly prompt_all_adults: {
255
- readonly type: ParameterType.BOOL;
256
- readonly default: false;
257
- };
258
- readonly prompt_only_adults: {
259
- readonly type: ParameterType.BOOL;
260
- readonly default: false;
261
- };
262
- readonly consent_statement_text: {
263
- readonly type: ParameterType.STRING;
264
- readonly default: "";
265
- };
266
- readonly omit_injury_phrase: {
267
- readonly type: ParameterType.BOOL;
268
- readonly default: false;
269
- };
270
- };
271
- };
272
- private readonly recorder;
273
- private readonly video_container_id;
274
- /**
275
- * Instantiate video consent plugin.
276
- *
277
- * @param jsPsych - JsPsych object
278
- */
279
- constructor(jsPsych: JsPsych);
280
- /**
281
- * Create/Show trial view.
282
- *
283
- * @param display - HTML element for experiment.
284
- * @param trial - Trial data including user supplied parameters.
285
- */
286
- trial(display: HTMLElement, trial: TrialType<Info>): void;
287
- /**
288
- * Retrieve video container element.
289
- *
290
- * @param display - HTML element for experiment.
291
- * @returns Video container
292
- */
293
- private getVideoContainer;
294
- /**
295
- * Add webcam feed to HTML.
296
- *
297
- * @param display - HTML element for experiment.
298
- */
299
- private recordFeed;
300
- /**
301
- * Playback Feed
302
- *
303
- * @param display - JsPsych display HTML element.
304
- */
305
- private playbackFeed;
306
- /**
307
- * Put back the webcam feed once the video recording has ended. This is used
308
- * with the "ended" Event.
309
- *
310
- * @param display - JsPsych display HTML element.
311
- * @returns Event function
312
- */
313
- private onEnded;
314
- /**
315
- * Retrieve button element from DOM.
316
- *
317
- * @param display - HTML element for experiment.
318
- * @param id - Element id
319
- * @returns Button element
320
- */
321
- private getButton;
322
- /**
323
- * Select and return the image element.
324
- *
325
- * @param display - HTML element for experiment.
326
- * @param id - ID string of Image element
327
- * @returns Image Element
328
- */
329
- private getImg;
330
- /**
331
- * Add record button to HTML.
332
- *
333
- * @param display - HTML element for experiment.
334
- */
335
- private recordButton;
336
- /**
337
- * Set up play button to playback last recorded video.
338
- *
339
- * @param display - HTML element for experiment.
340
- */
341
- private playButton;
342
- /**
343
- * Add stop button to HTML.
344
- *
345
- * @param display - HTML element for experiment.
346
- */
347
- private stopButton;
348
- /**
349
- * Add next button to HTML.
350
- *
351
- * @param display - HTML element for experiment.
352
- */
353
- private nextButton;
354
- /**
355
- * Mark the response in the lookit-api database as having completed the
356
- * consent frame, then finish the trial.
357
- */
358
- private endTrial;
359
- /**
360
- * Add CHS type to experiment data. This will enable Lookit API to run the
361
- * "consent" Frame Action Dispatcher method after the experiment has
362
- * completed.
363
- *
364
- * @returns Object containing CHS type.
365
- */
366
- static chsData(): {
367
- chs_type: string;
368
- };
369
- }
370
- export {};
package/dist/errors.d.ts DELETED
@@ -1,149 +0,0 @@
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
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Audio Worklet Processor class for processing audio input streams. This is
3
- * used by the Recorder to run a volume check on the microphone input stream.
4
- * Source:
5
- * https://www.webrtc-developers.com/how-to-know-if-my-microphone-works/#detect-noise-or-silence
6
- */
7
- export default class MicCheckProcessor extends AudioWorkletProcessor {
8
- private _volume;
9
- private _micChecked;
10
- /** Constructor for the mic check processor. */
11
- constructor();
12
- /**
13
- * Process method that implements the audio processing algorithm for the Audio
14
- * Processor Worklet. "Although the method is not a part of the
15
- * AudioWorkletProcessor interface, any implementation of
16
- * AudioWorkletProcessor must provide a process() method." Source:
17
- * https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor/process
18
- * The process method can take the following arguments: inputs, outputs,
19
- * parameters. Here we are only using inputs.
20
- *
21
- * @param inputs - An array of inputs from the audio stream (microphone)
22
- * connnected to the node. Each item in the inputs array is an array of
23
- * channels. Each channel is a Float32Array containing 128 samples. For
24
- * example, inputs[n][m][i] will access n-th input, m-th channel of that
25
- * input, and i-th sample of that channel.
26
- * @returns Boolean indicating whether or not the Audio Worklet Node should
27
- * remain active, even if the User Agent thinks it is safe to shut down. In
28
- * this case, when the recorder decides that the mic check criteria has been
29
- * met, it will return false (processor should be shut down), otherwise it
30
- * will return true (processor should remain active).
31
- */
32
- process(inputs: Float32Array[][]): boolean;
33
- }