jspsych 8.2.0 → 8.2.2
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 +1 -1
- package/dist/index.browser.js +34 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +6 -6
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +33 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/JsPsych.ts +4 -3
- package/src/modules/plugin-api/MediaAPI.ts +28 -1
- package/src/timeline/Timeline.spec.ts +2 -2
- package/src/timeline/Trial.spec.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jspsych",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.2",
|
|
4
4
|
"description": "Behavioral experiments in a browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@fontsource/open-sans": "4.5.3",
|
|
51
|
-
"@jspsych/config": "^3.
|
|
51
|
+
"@jspsych/config": "^3.3.0",
|
|
52
52
|
"@types/dom-mediacapture-record": "^1.0.11",
|
|
53
53
|
"base64-inline-loader": "^2.0.1",
|
|
54
54
|
"css-loader": "^6.6.0",
|
package/src/JsPsych.ts
CHANGED
|
@@ -36,6 +36,9 @@ export class JsPsych {
|
|
|
36
36
|
return version;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
private citation: any = '__CITATIONS__';
|
|
41
|
+
|
|
39
42
|
/** Options */
|
|
40
43
|
private options: any = {};
|
|
41
44
|
|
|
@@ -274,8 +277,6 @@ export class JsPsych {
|
|
|
274
277
|
format: "apa" | "bibtex" = "apa"
|
|
275
278
|
) {
|
|
276
279
|
const formatOptions = ["apa", "bibtex"];
|
|
277
|
-
// prettier-ignore
|
|
278
|
-
const jsPsychCitations: any = '__CITATIONS__';
|
|
279
280
|
format = format.toLowerCase() as "apa" | "bibtex";
|
|
280
281
|
// Check if plugins is an array
|
|
281
282
|
if (!Array.isArray(plugins)) {
|
|
@@ -287,7 +288,7 @@ export class JsPsych {
|
|
|
287
288
|
}
|
|
288
289
|
// Print citations
|
|
289
290
|
else {
|
|
290
|
-
const jsPsychCitation =
|
|
291
|
+
const jsPsychCitation = this.citation[format];
|
|
291
292
|
const citationSet = new Set([jsPsychCitation]);
|
|
292
293
|
|
|
293
294
|
for (const plugin of plugins) {
|
|
@@ -284,11 +284,38 @@ export class MediaAPI {
|
|
|
284
284
|
private camera_recorder: MediaRecorder = null;
|
|
285
285
|
|
|
286
286
|
initializeCameraRecorder(stream: MediaStream, opts?: MediaRecorderOptions) {
|
|
287
|
+
let mimeType = this.getCompatibleMimeType() || "video/webm";
|
|
288
|
+
const recorderOptions: MediaRecorderOptions = {
|
|
289
|
+
...opts,
|
|
290
|
+
mimeType
|
|
291
|
+
}
|
|
292
|
+
|
|
287
293
|
this.camera_stream = stream;
|
|
288
|
-
const recorder = new MediaRecorder(stream,
|
|
294
|
+
const recorder = new MediaRecorder(stream, recorderOptions);
|
|
289
295
|
this.camera_recorder = recorder;
|
|
290
296
|
}
|
|
291
297
|
|
|
298
|
+
// mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
|
|
299
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
300
|
+
private getCompatibleMimeType(): string {
|
|
301
|
+
const types = [
|
|
302
|
+
// chrome firefox edge
|
|
303
|
+
"video/webm;codecs=vp9,opus",
|
|
304
|
+
"video/webm;codecs=vp8,opus",
|
|
305
|
+
// general
|
|
306
|
+
"video/mp4;codecs=avc1.42E01E,mp4a.40.2",
|
|
307
|
+
// safari
|
|
308
|
+
"video/mp4;codecs=h264,aac",
|
|
309
|
+
"video/mp4;codecs=hevc,aac",
|
|
310
|
+
]
|
|
311
|
+
for (const mimeType of types) {
|
|
312
|
+
if (MediaRecorder.isTypeSupported(mimeType)) {
|
|
313
|
+
return mimeType;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
|
|
292
319
|
getCameraStream(): MediaStream {
|
|
293
320
|
return this.camera_stream;
|
|
294
321
|
}
|
|
@@ -586,10 +586,10 @@ describe("Timeline", () => {
|
|
|
586
586
|
const variable = new TimelineVariable("x");
|
|
587
587
|
|
|
588
588
|
await timeline.run();
|
|
589
|
-
expect(() => timeline.evaluateTimelineVariable(variable)).
|
|
589
|
+
expect(() => timeline.evaluateTimelineVariable(variable)).toThrow();
|
|
590
590
|
expect(() =>
|
|
591
591
|
(timeline.children[0] as Timeline).evaluateTimelineVariable(variable)
|
|
592
|
-
).
|
|
592
|
+
).toThrow();
|
|
593
593
|
});
|
|
594
594
|
});
|
|
595
595
|
});
|
|
@@ -524,7 +524,7 @@ describe("Trial", () => {
|
|
|
524
524
|
);
|
|
525
525
|
await expect(
|
|
526
526
|
createTrial({ type: TestPlugin, requiredComplexNested: {} }).run()
|
|
527
|
-
).rejects.
|
|
527
|
+
).rejects.toThrow('"requiredComplexNested.requiredChild" parameter');
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
it("errors on missing parameters nested in `COMPLEX` array parameters", async () => {
|