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/dist/index.d.ts
CHANGED
|
@@ -666,6 +666,8 @@ declare class MediaAPI {
|
|
|
666
666
|
private camera_stream;
|
|
667
667
|
private camera_recorder;
|
|
668
668
|
initializeCameraRecorder(stream: MediaStream, opts?: MediaRecorderOptions): void;
|
|
669
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
670
|
+
private getCompatibleMimeType;
|
|
669
671
|
getCameraStream(): MediaStream;
|
|
670
672
|
getCameraRecorder(): MediaRecorder;
|
|
671
673
|
}
|
|
@@ -907,6 +909,7 @@ declare class JsPsych {
|
|
|
907
909
|
data: JsPsychData;
|
|
908
910
|
pluginAPI: PluginAPI;
|
|
909
911
|
version(): string;
|
|
912
|
+
private citation;
|
|
910
913
|
/** Options */
|
|
911
914
|
private options;
|
|
912
915
|
/** Experiment timeline */
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import autoBind from 'auto-bind';
|
|
|
2
2
|
import rw from 'random-words';
|
|
3
3
|
import seedrandom from 'seedrandom/lib/alea.js';
|
|
4
4
|
|
|
5
|
-
var version = "8.2.
|
|
5
|
+
var version = "8.2.2";
|
|
6
6
|
|
|
7
7
|
class ExtensionManager {
|
|
8
8
|
constructor(dependencies, extensionsConfiguration) {
|
|
@@ -967,10 +967,35 @@ class MediaAPI {
|
|
|
967
967
|
return this.microphone_recorder;
|
|
968
968
|
}
|
|
969
969
|
initializeCameraRecorder(stream, opts) {
|
|
970
|
+
let mimeType = this.getCompatibleMimeType() || "video/webm";
|
|
971
|
+
const recorderOptions = {
|
|
972
|
+
...opts,
|
|
973
|
+
mimeType
|
|
974
|
+
};
|
|
970
975
|
this.camera_stream = stream;
|
|
971
|
-
const recorder = new MediaRecorder(stream,
|
|
976
|
+
const recorder = new MediaRecorder(stream, recorderOptions);
|
|
972
977
|
this.camera_recorder = recorder;
|
|
973
978
|
}
|
|
979
|
+
// mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
|
|
980
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
981
|
+
getCompatibleMimeType() {
|
|
982
|
+
const types = [
|
|
983
|
+
// chrome firefox edge
|
|
984
|
+
"video/webm;codecs=vp9,opus",
|
|
985
|
+
"video/webm;codecs=vp8,opus",
|
|
986
|
+
// general
|
|
987
|
+
"video/mp4;codecs=avc1.42E01E,mp4a.40.2",
|
|
988
|
+
// safari
|
|
989
|
+
"video/mp4;codecs=h264,aac",
|
|
990
|
+
"video/mp4;codecs=hevc,aac"
|
|
991
|
+
];
|
|
992
|
+
for (const mimeType of types) {
|
|
993
|
+
if (MediaRecorder.isTypeSupported(mimeType)) {
|
|
994
|
+
return mimeType;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
974
999
|
getCameraStream() {
|
|
975
1000
|
return this.camera_stream;
|
|
976
1001
|
}
|
|
@@ -2310,6 +2335,11 @@ class JsPsych {
|
|
|
2310
2335
|
this.turk = turk;
|
|
2311
2336
|
this.randomization = randomization;
|
|
2312
2337
|
this.utils = utils;
|
|
2338
|
+
// prettier-ignore
|
|
2339
|
+
this.citation = {
|
|
2340
|
+
"apa": "de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 ",
|
|
2341
|
+
"bibtex": '@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '
|
|
2342
|
+
};
|
|
2313
2343
|
/** Options */
|
|
2314
2344
|
this.options = {};
|
|
2315
2345
|
/**
|
|
@@ -2529,17 +2559,13 @@ class JsPsych {
|
|
|
2529
2559
|
*/
|
|
2530
2560
|
getCitations(plugins = [], format = "apa") {
|
|
2531
2561
|
const formatOptions = ["apa", "bibtex"];
|
|
2532
|
-
const jsPsychCitations = {
|
|
2533
|
-
"apa": "de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 ",
|
|
2534
|
-
"bibtex": '@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '
|
|
2535
|
-
};
|
|
2536
2562
|
format = format.toLowerCase();
|
|
2537
2563
|
if (!Array.isArray(plugins)) {
|
|
2538
2564
|
throw new Error("Expected array of plugins/extensions");
|
|
2539
2565
|
} else if (!formatOptions.includes(format)) {
|
|
2540
2566
|
throw new Error("Unsupported citation format");
|
|
2541
2567
|
} else {
|
|
2542
|
-
const jsPsychCitation =
|
|
2568
|
+
const jsPsychCitation = this.citation[format];
|
|
2543
2569
|
const citationSet = /* @__PURE__ */ new Set([jsPsychCitation]);
|
|
2544
2570
|
for (const plugin of plugins) {
|
|
2545
2571
|
try {
|