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.js
CHANGED
|
@@ -67,7 +67,7 @@ var autoBind = (self, {include, exclude} = {}) => {
|
|
|
67
67
|
return self;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
var version = "7.3.
|
|
70
|
+
var version = "7.3.2";
|
|
71
71
|
|
|
72
72
|
class MigrationError extends Error {
|
|
73
73
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -900,15 +900,15 @@ class MediaAPI {
|
|
|
900
900
|
callback_error({ source: source, error: e });
|
|
901
901
|
});
|
|
902
902
|
};
|
|
903
|
-
request.onerror =
|
|
903
|
+
request.onerror = (e) => {
|
|
904
904
|
let err = e;
|
|
905
|
-
if (
|
|
905
|
+
if (request.status == 404) {
|
|
906
906
|
err = "404";
|
|
907
907
|
}
|
|
908
908
|
callback_error({ source: source, error: err });
|
|
909
909
|
};
|
|
910
|
-
request.onloadend =
|
|
911
|
-
if (
|
|
910
|
+
request.onloadend = (e) => {
|
|
911
|
+
if (request.status == 404) {
|
|
912
912
|
callback_error({ source: source, error: "404" });
|
|
913
913
|
}
|
|
914
914
|
};
|
|
@@ -965,20 +965,21 @@ class MediaAPI {
|
|
|
965
965
|
callback_complete();
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
968
|
-
for (
|
|
969
|
-
|
|
970
|
-
|
|
968
|
+
for (let i = 0; i < images.length; i++) {
|
|
969
|
+
const img = new Image();
|
|
970
|
+
const src = images[i];
|
|
971
|
+
img.onload = () => {
|
|
971
972
|
n_loaded++;
|
|
972
|
-
callback_load(
|
|
973
|
+
callback_load(src);
|
|
973
974
|
if (n_loaded === images.length) {
|
|
974
975
|
callback_complete();
|
|
975
976
|
}
|
|
976
977
|
};
|
|
977
|
-
img.onerror =
|
|
978
|
-
callback_error({ source:
|
|
978
|
+
img.onerror = (e) => {
|
|
979
|
+
callback_error({ source: src, error: e });
|
|
979
980
|
};
|
|
980
|
-
img.src =
|
|
981
|
-
this.img_cache[
|
|
981
|
+
img.src = src;
|
|
982
|
+
this.img_cache[src] = img;
|
|
982
983
|
this.preload_requests.push(img);
|
|
983
984
|
}
|
|
984
985
|
}
|
|
@@ -996,9 +997,9 @@ class MediaAPI {
|
|
|
996
997
|
const request = new XMLHttpRequest();
|
|
997
998
|
request.open("GET", video, true);
|
|
998
999
|
request.responseType = "blob";
|
|
999
|
-
request.onload =
|
|
1000
|
-
if (
|
|
1001
|
-
const videoBlob =
|
|
1000
|
+
request.onload = () => {
|
|
1001
|
+
if (request.status === 200 || request.status === 0) {
|
|
1002
|
+
const videoBlob = request.response;
|
|
1002
1003
|
video_buffers[video] = URL.createObjectURL(videoBlob); // IE10+
|
|
1003
1004
|
n_loaded++;
|
|
1004
1005
|
callback_load(video);
|
|
@@ -1007,15 +1008,15 @@ class MediaAPI {
|
|
|
1007
1008
|
}
|
|
1008
1009
|
}
|
|
1009
1010
|
};
|
|
1010
|
-
request.onerror =
|
|
1011
|
+
request.onerror = (e) => {
|
|
1011
1012
|
let err = e;
|
|
1012
|
-
if (
|
|
1013
|
+
if (request.status == 404) {
|
|
1013
1014
|
err = "404";
|
|
1014
1015
|
}
|
|
1015
1016
|
callback_error({ source: video, error: err });
|
|
1016
1017
|
};
|
|
1017
|
-
request.onloadend =
|
|
1018
|
-
if (
|
|
1018
|
+
request.onloadend = (e) => {
|
|
1019
|
+
if (request.status == 404) {
|
|
1019
1020
|
callback_error({ source: video, error: "404" });
|
|
1020
1021
|
}
|
|
1021
1022
|
};
|
|
@@ -1872,7 +1873,8 @@ function shuffleNoRepeats(arr, equalityTest) {
|
|
|
1872
1873
|
// test to make sure the new neighbor isn't equal to the old one
|
|
1873
1874
|
while (equalityTest(random_shuffle[i + 1], random_shuffle[random_pick]) ||
|
|
1874
1875
|
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick + 1]) ||
|
|
1875
|
-
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1])
|
|
1876
|
+
equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1]) ||
|
|
1877
|
+
equalityTest(random_shuffle[i], random_shuffle[random_pick])) {
|
|
1876
1878
|
random_pick = Math.floor(Math.random() * (random_shuffle.length - 2)) + 1;
|
|
1877
1879
|
}
|
|
1878
1880
|
const new_neighbor = random_shuffle[random_pick];
|
|
@@ -3183,20 +3185,21 @@ class JsPsych {
|
|
|
3183
3185
|
for (const param in trial.type.info.parameters) {
|
|
3184
3186
|
// check if parameter is complex with nested defaults
|
|
3185
3187
|
if (trial.type.info.parameters[param].type === ParameterType.COMPLEX) {
|
|
3186
|
-
if
|
|
3188
|
+
// check if parameter is undefined and has a default value
|
|
3189
|
+
if (typeof trial[param] === "undefined" && trial.type.info.parameters[param].default) {
|
|
3190
|
+
trial[param] = trial.type.info.parameters[param].default;
|
|
3191
|
+
}
|
|
3192
|
+
// if parameter is an array, iterate over each entry after confirming that there are
|
|
3193
|
+
// entries to iterate over. this is common when some parameters in a COMPLEX type have
|
|
3194
|
+
// default values and others do not.
|
|
3195
|
+
if (trial.type.info.parameters[param].array === true && Array.isArray(trial[param])) {
|
|
3187
3196
|
// iterate over each entry in the array
|
|
3188
3197
|
trial[param].forEach(function (ip, i) {
|
|
3189
3198
|
// check each parameter in the plugin description
|
|
3190
3199
|
for (const p in trial.type.info.parameters[param].nested) {
|
|
3191
3200
|
if (typeof trial[param][i][p] === "undefined" || trial[param][i][p] === null) {
|
|
3192
3201
|
if (typeof trial.type.info.parameters[param].nested[p].default === "undefined") {
|
|
3193
|
-
console.error(
|
|
3194
|
-
p +
|
|
3195
|
-
" parameter (nested in the " +
|
|
3196
|
-
param +
|
|
3197
|
-
" parameter) in the " +
|
|
3198
|
-
trial.type +
|
|
3199
|
-
" plugin.");
|
|
3202
|
+
console.error(`You must specify a value for the ${p} parameter (nested in the ${param} parameter) in the ${trial.type.info.name} plugin.`);
|
|
3200
3203
|
}
|
|
3201
3204
|
else {
|
|
3202
3205
|
trial[param][i][p] = trial.type.info.parameters[param].nested[p].default;
|
|
@@ -3209,11 +3212,7 @@ class JsPsych {
|
|
|
3209
3212
|
// if it's not nested, checking is much easier and do that here:
|
|
3210
3213
|
else if (typeof trial[param] === "undefined" || trial[param] === null) {
|
|
3211
3214
|
if (typeof trial.type.info.parameters[param].default === "undefined") {
|
|
3212
|
-
console.error(
|
|
3213
|
-
param +
|
|
3214
|
-
" parameter in the " +
|
|
3215
|
-
trial.type.info.name +
|
|
3216
|
-
" plugin.");
|
|
3215
|
+
console.error(`You must specify a value for the ${param} parameter in the ${trial.type.info.name} plugin.`);
|
|
3217
3216
|
}
|
|
3218
3217
|
else {
|
|
3219
3218
|
trial[param] = trial.type.info.parameters[param].default;
|