jspsych 7.3.0 → 7.3.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/dist/index.browser.js +33 -34
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +33 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/JsPsych.ts +10 -13
- package/src/modules/plugin-api/MediaAPI.ts +20 -20
- package/src/modules/randomization.ts +3 -1
package/dist/index.browser.js
CHANGED
|
@@ -70,7 +70,7 @@ var jsPsychModule = (function (exports) {
|
|
|
70
70
|
return self;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
var version = "7.3.
|
|
73
|
+
var version = "7.3.2";
|
|
74
74
|
|
|
75
75
|
class MigrationError extends Error {
|
|
76
76
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -903,15 +903,15 @@ var jsPsychModule = (function (exports) {
|
|
|
903
903
|
callback_error({ source: source, error: e });
|
|
904
904
|
});
|
|
905
905
|
};
|
|
906
|
-
request.onerror =
|
|
906
|
+
request.onerror = (e) => {
|
|
907
907
|
let err = e;
|
|
908
|
-
if (
|
|
908
|
+
if (request.status == 404) {
|
|
909
909
|
err = "404";
|
|
910
910
|
}
|
|
911
911
|
callback_error({ source: source, error: err });
|
|
912
912
|
};
|
|
913
|
-
request.onloadend =
|
|
914
|
-
if (
|
|
913
|
+
request.onloadend = (e) => {
|
|
914
|
+
if (request.status == 404) {
|
|
915
915
|
callback_error({ source: source, error: "404" });
|
|
916
916
|
}
|
|
917
917
|
};
|
|
@@ -968,20 +968,21 @@ var jsPsychModule = (function (exports) {
|
|
|
968
968
|
callback_complete();
|
|
969
969
|
return;
|
|
970
970
|
}
|
|
971
|
-
for (
|
|
972
|
-
|
|
973
|
-
|
|
971
|
+
for (let i = 0; i < images.length; i++) {
|
|
972
|
+
const img = new Image();
|
|
973
|
+
const src = images[i];
|
|
974
|
+
img.onload = () => {
|
|
974
975
|
n_loaded++;
|
|
975
|
-
callback_load(
|
|
976
|
+
callback_load(src);
|
|
976
977
|
if (n_loaded === images.length) {
|
|
977
978
|
callback_complete();
|
|
978
979
|
}
|
|
979
980
|
};
|
|
980
|
-
img.onerror =
|
|
981
|
-
callback_error({ source:
|
|
981
|
+
img.onerror = (e) => {
|
|
982
|
+
callback_error({ source: src, error: e });
|
|
982
983
|
};
|
|
983
|
-
img.src =
|
|
984
|
-
this.img_cache[
|
|
984
|
+
img.src = src;
|
|
985
|
+
this.img_cache[src] = img;
|
|
985
986
|
this.preload_requests.push(img);
|
|
986
987
|
}
|
|
987
988
|
}
|
|
@@ -999,9 +1000,9 @@ var jsPsychModule = (function (exports) {
|
|
|
999
1000
|
const request = new XMLHttpRequest();
|
|
1000
1001
|
request.open("GET", video, true);
|
|
1001
1002
|
request.responseType = "blob";
|
|
1002
|
-
request.onload =
|
|
1003
|
-
if (
|
|
1004
|
-
const videoBlob =
|
|
1003
|
+
request.onload = () => {
|
|
1004
|
+
if (request.status === 200 || request.status === 0) {
|
|
1005
|
+
const videoBlob = request.response;
|
|
1005
1006
|
video_buffers[video] = URL.createObjectURL(videoBlob); // IE10+
|
|
1006
1007
|
n_loaded++;
|
|
1007
1008
|
callback_load(video);
|
|
@@ -1010,15 +1011,15 @@ var jsPsychModule = (function (exports) {
|
|
|
1010
1011
|
}
|
|
1011
1012
|
}
|
|
1012
1013
|
};
|
|
1013
|
-
request.onerror =
|
|
1014
|
+
request.onerror = (e) => {
|
|
1014
1015
|
let err = e;
|
|
1015
|
-
if (
|
|
1016
|
+
if (request.status == 404) {
|
|
1016
1017
|
err = "404";
|
|
1017
1018
|
}
|
|
1018
1019
|
callback_error({ source: video, error: err });
|
|
1019
1020
|
};
|
|
1020
|
-
request.onloadend =
|
|
1021
|
-
if (
|
|
1021
|
+
request.onloadend = (e) => {
|
|
1022
|
+
if (request.status == 404) {
|
|
1022
1023
|
callback_error({ source: video, error: "404" });
|
|
1023
1024
|
}
|
|
1024
1025
|
};
|
|
@@ -1875,7 +1876,8 @@ var jsPsychModule = (function (exports) {
|
|
|
1875
1876
|
// test to make sure the new neighbor isn't equal to the old one
|
|
1876
1877
|
while (equalityTest(random_shuffle[i + 1], random_shuffle[random_pick]) ||
|
|
1877
1878
|
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick + 1]) ||
|
|
1878
|
-
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1])
|
|
1879
|
+
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1]) ||
|
|
1880
|
+
equalityTest(random_shuffle[i], random_shuffle[random_pick])) {
|
|
1879
1881
|
random_pick = Math.floor(Math.random() * (random_shuffle.length - 2)) + 1;
|
|
1880
1882
|
}
|
|
1881
1883
|
const new_neighbor = random_shuffle[random_pick];
|
|
@@ -3186,20 +3188,21 @@ var jsPsychModule = (function (exports) {
|
|
|
3186
3188
|
for (const param in trial.type.info.parameters) {
|
|
3187
3189
|
// check if parameter is complex with nested defaults
|
|
3188
3190
|
if (trial.type.info.parameters[param].type === exports.ParameterType.COMPLEX) {
|
|
3189
|
-
if
|
|
3191
|
+
// check if parameter is undefined and has a default value
|
|
3192
|
+
if (typeof trial[param] === "undefined" && trial.type.info.parameters[param].default) {
|
|
3193
|
+
trial[param] = trial.type.info.parameters[param].default;
|
|
3194
|
+
}
|
|
3195
|
+
// if parameter is an array, iterate over each entry after confirming that there are
|
|
3196
|
+
// entries to iterate over. this is common when some parameters in a COMPLEX type have
|
|
3197
|
+
// default values and others do not.
|
|
3198
|
+
if (trial.type.info.parameters[param].array === true && Array.isArray(trial[param])) {
|
|
3190
3199
|
// iterate over each entry in the array
|
|
3191
3200
|
trial[param].forEach(function (ip, i) {
|
|
3192
3201
|
// check each parameter in the plugin description
|
|
3193
3202
|
for (const p in trial.type.info.parameters[param].nested) {
|
|
3194
3203
|
if (typeof trial[param][i][p] === "undefined" || trial[param][i][p] === null) {
|
|
3195
3204
|
if (typeof trial.type.info.parameters[param].nested[p].default === "undefined") {
|
|
3196
|
-
console.error(
|
|
3197
|
-
p +
|
|
3198
|
-
" parameter (nested in the " +
|
|
3199
|
-
param +
|
|
3200
|
-
" parameter) in the " +
|
|
3201
|
-
trial.type +
|
|
3202
|
-
" plugin.");
|
|
3205
|
+
console.error(`You must specify a value for the ${p} parameter (nested in the ${param} parameter) in the ${trial.type.info.name} plugin.`);
|
|
3203
3206
|
}
|
|
3204
3207
|
else {
|
|
3205
3208
|
trial[param][i][p] = trial.type.info.parameters[param].nested[p].default;
|
|
@@ -3212,11 +3215,7 @@ var jsPsychModule = (function (exports) {
|
|
|
3212
3215
|
// if it's not nested, checking is much easier and do that here:
|
|
3213
3216
|
else if (typeof trial[param] === "undefined" || trial[param] === null) {
|
|
3214
3217
|
if (typeof trial.type.info.parameters[param].default === "undefined") {
|
|
3215
|
-
console.error(
|
|
3216
|
-
param +
|
|
3217
|
-
" parameter in the " +
|
|
3218
|
-
trial.type.info.name +
|
|
3219
|
-
" plugin.");
|
|
3218
|
+
console.error(`You must specify a value for the ${param} parameter in the ${trial.type.info.name} plugin.`);
|
|
3220
3219
|
}
|
|
3221
3220
|
else {
|
|
3222
3221
|
trial[param] = trial.type.info.parameters[param].default;
|