jspsych 7.0.0 → 7.1.0
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/JsPsych.d.ts +10 -1
- package/dist/index.browser.js +706 -7
- 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 +706 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +706 -7
- package/dist/index.js.map +1 -1
- package/dist/migration.d.ts +3 -0
- package/dist/modules/plugin-api/MediaAPI.d.ts +3 -0
- package/dist/modules/plugin-api/SimulationAPI.d.ts +41 -0
- package/dist/modules/plugin-api/index.d.ts +2 -1
- package/dist/modules/randomization.d.ts +28 -1
- package/package.json +6 -4
- package/src/JsPsych.ts +85 -4
- package/src/index.ts +37 -1
- package/src/migration.ts +37 -0
- package/src/modules/plugin-api/MediaAPI.ts +11 -0
- package/src/modules/plugin-api/SimulationAPI.ts +181 -0
- package/src/modules/plugin-api/index.ts +3 -1
- package/src/modules/randomization.ts +72 -1
package/dist/index.browser.js
CHANGED
|
@@ -68,7 +68,38 @@ var jsPsychModule = (function (exports) {
|
|
|
68
68
|
return self;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
var version = "7.
|
|
71
|
+
var version = "7.1.0";
|
|
72
|
+
|
|
73
|
+
class MigrationError extends Error {
|
|
74
|
+
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
75
|
+
super(`${message} Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment.`);
|
|
76
|
+
this.name = "MigrationError";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Define a global jsPsych object to handle invocations on it with migration errors
|
|
80
|
+
window.jsPsych = {
|
|
81
|
+
get init() {
|
|
82
|
+
throw new MigrationError("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.");
|
|
83
|
+
},
|
|
84
|
+
get data() {
|
|
85
|
+
throw new MigrationError();
|
|
86
|
+
},
|
|
87
|
+
get randomization() {
|
|
88
|
+
throw new MigrationError();
|
|
89
|
+
},
|
|
90
|
+
get turk() {
|
|
91
|
+
throw new MigrationError();
|
|
92
|
+
},
|
|
93
|
+
get pluginAPI() {
|
|
94
|
+
throw new MigrationError();
|
|
95
|
+
},
|
|
96
|
+
get ALL_KEYS() {
|
|
97
|
+
throw new MigrationError('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.');
|
|
98
|
+
},
|
|
99
|
+
get NO_KEYS() {
|
|
100
|
+
throw new MigrationError('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.');
|
|
101
|
+
},
|
|
102
|
+
};
|
|
72
103
|
|
|
73
104
|
/**
|
|
74
105
|
* Finds all of the unique items in an array.
|
|
@@ -798,6 +829,7 @@ var jsPsychModule = (function (exports) {
|
|
|
798
829
|
this.preload_requests = [];
|
|
799
830
|
this.img_cache = {};
|
|
800
831
|
this.preloadMap = new Map();
|
|
832
|
+
this.microphone_recorder = null;
|
|
801
833
|
}
|
|
802
834
|
getVideoBuffer(videoID) {
|
|
803
835
|
return this.video_buffers[videoID];
|
|
@@ -1034,6 +1066,184 @@ var jsPsychModule = (function (exports) {
|
|
|
1034
1066
|
}
|
|
1035
1067
|
this.preload_requests = [];
|
|
1036
1068
|
}
|
|
1069
|
+
initializeMicrophoneRecorder(stream) {
|
|
1070
|
+
const recorder = new MediaRecorder(stream);
|
|
1071
|
+
this.microphone_recorder = recorder;
|
|
1072
|
+
}
|
|
1073
|
+
getMicrophoneRecorder() {
|
|
1074
|
+
return this.microphone_recorder;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
class SimulationAPI {
|
|
1079
|
+
dispatchEvent(event) {
|
|
1080
|
+
document.body.dispatchEvent(event);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Dispatches a `keydown` event for the specified key
|
|
1084
|
+
* @param key Character code (`.key` property) for the key to press.
|
|
1085
|
+
*/
|
|
1086
|
+
keyDown(key) {
|
|
1087
|
+
this.dispatchEvent(new KeyboardEvent("keydown", { key }));
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Dispatches a `keyup` event for the specified key
|
|
1091
|
+
* @param key Character code (`.key` property) for the key to press.
|
|
1092
|
+
*/
|
|
1093
|
+
keyUp(key) {
|
|
1094
|
+
this.dispatchEvent(new KeyboardEvent("keyup", { key }));
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Dispatches a `keydown` and `keyup` event in sequence to simulate pressing a key.
|
|
1098
|
+
* @param key Character code (`.key` property) for the key to press.
|
|
1099
|
+
* @param delay Length of time to wait (ms) before executing action
|
|
1100
|
+
*/
|
|
1101
|
+
pressKey(key, delay = 0) {
|
|
1102
|
+
if (delay > 0) {
|
|
1103
|
+
setTimeout(() => {
|
|
1104
|
+
this.keyDown(key);
|
|
1105
|
+
this.keyUp(key);
|
|
1106
|
+
}, delay);
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
this.keyDown(key);
|
|
1110
|
+
this.keyUp(key);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Dispatches `mousedown`, `mouseup`, and `click` events on the target element
|
|
1115
|
+
* @param target The element to click
|
|
1116
|
+
* @param delay Length of time to wait (ms) before executing action
|
|
1117
|
+
*/
|
|
1118
|
+
clickTarget(target, delay = 0) {
|
|
1119
|
+
if (delay > 0) {
|
|
1120
|
+
setTimeout(() => {
|
|
1121
|
+
target.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
|
|
1122
|
+
target.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
|
|
1123
|
+
target.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
1124
|
+
}, delay);
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
target.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
|
|
1128
|
+
target.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
|
|
1129
|
+
target.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Sets the value of a target text input
|
|
1134
|
+
* @param target A text input element to fill in
|
|
1135
|
+
* @param text Text to input
|
|
1136
|
+
* @param delay Length of time to wait (ms) before executing action
|
|
1137
|
+
*/
|
|
1138
|
+
fillTextInput(target, text, delay = 0) {
|
|
1139
|
+
if (delay > 0) {
|
|
1140
|
+
setTimeout(() => {
|
|
1141
|
+
target.value = text;
|
|
1142
|
+
}, delay);
|
|
1143
|
+
}
|
|
1144
|
+
else {
|
|
1145
|
+
target.value = text;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Picks a valid key from `choices`, taking into account jsPsych-specific
|
|
1150
|
+
* identifiers like "NO_KEYS" and "ALL_KEYS".
|
|
1151
|
+
* @param choices Which keys are valid.
|
|
1152
|
+
* @returns A key selected at random from the valid keys.
|
|
1153
|
+
*/
|
|
1154
|
+
getValidKey(choices) {
|
|
1155
|
+
const possible_keys = [
|
|
1156
|
+
"a",
|
|
1157
|
+
"b",
|
|
1158
|
+
"c",
|
|
1159
|
+
"d",
|
|
1160
|
+
"e",
|
|
1161
|
+
"f",
|
|
1162
|
+
"g",
|
|
1163
|
+
"h",
|
|
1164
|
+
"i",
|
|
1165
|
+
"j",
|
|
1166
|
+
"k",
|
|
1167
|
+
"l",
|
|
1168
|
+
"m",
|
|
1169
|
+
"n",
|
|
1170
|
+
"o",
|
|
1171
|
+
"p",
|
|
1172
|
+
"q",
|
|
1173
|
+
"r",
|
|
1174
|
+
"s",
|
|
1175
|
+
"t",
|
|
1176
|
+
"u",
|
|
1177
|
+
"v",
|
|
1178
|
+
"w",
|
|
1179
|
+
"x",
|
|
1180
|
+
"y",
|
|
1181
|
+
"z",
|
|
1182
|
+
"0",
|
|
1183
|
+
"1",
|
|
1184
|
+
"2",
|
|
1185
|
+
"3",
|
|
1186
|
+
"4",
|
|
1187
|
+
"5",
|
|
1188
|
+
"6",
|
|
1189
|
+
"7",
|
|
1190
|
+
"8",
|
|
1191
|
+
"9",
|
|
1192
|
+
" ",
|
|
1193
|
+
];
|
|
1194
|
+
let key;
|
|
1195
|
+
if (choices == "NO_KEYS") {
|
|
1196
|
+
key = null;
|
|
1197
|
+
}
|
|
1198
|
+
else if (choices == "ALL_KEYS") {
|
|
1199
|
+
key = possible_keys[Math.floor(Math.random() * possible_keys.length)];
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
const flat_choices = choices.flat();
|
|
1203
|
+
key = flat_choices[Math.floor(Math.random() * flat_choices.length)];
|
|
1204
|
+
}
|
|
1205
|
+
return key;
|
|
1206
|
+
}
|
|
1207
|
+
mergeSimulationData(default_data, simulation_options) {
|
|
1208
|
+
// override any data with data from simulation object
|
|
1209
|
+
return Object.assign(Object.assign({}, default_data), simulation_options === null || simulation_options === void 0 ? void 0 : simulation_options.data);
|
|
1210
|
+
}
|
|
1211
|
+
ensureSimulationDataConsistency(trial, data) {
|
|
1212
|
+
// All RTs must be rounded
|
|
1213
|
+
if (data.rt) {
|
|
1214
|
+
data.rt = Math.round(data.rt);
|
|
1215
|
+
}
|
|
1216
|
+
// If a trial_duration and rt exist, make sure that the RT is not longer than the trial.
|
|
1217
|
+
if (trial.trial_duration && data.rt && data.rt > trial.trial_duration) {
|
|
1218
|
+
data.rt = null;
|
|
1219
|
+
if (data.response) {
|
|
1220
|
+
data.response = null;
|
|
1221
|
+
}
|
|
1222
|
+
if (data.correct) {
|
|
1223
|
+
data.correct = false;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
// If trial.choices is NO_KEYS make sure that response and RT are null
|
|
1227
|
+
if (trial.choices && trial.choices == "NO_KEYS") {
|
|
1228
|
+
if (data.rt) {
|
|
1229
|
+
data.rt = null;
|
|
1230
|
+
}
|
|
1231
|
+
if (data.response) {
|
|
1232
|
+
data.response = null;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
// If response is not allowed before stimulus display complete, ensure RT
|
|
1236
|
+
// is longer than display time.
|
|
1237
|
+
if (trial.allow_response_before_complete) {
|
|
1238
|
+
if (trial.sequence_reps && trial.frame_time) {
|
|
1239
|
+
const min_time = trial.sequence_reps * trial.frame_time * trial.stimuli.length;
|
|
1240
|
+
if (data.rt < min_time) {
|
|
1241
|
+
data.rt = null;
|
|
1242
|
+
data.response = null;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1037
1247
|
}
|
|
1038
1248
|
|
|
1039
1249
|
class TimeoutAPI {
|
|
@@ -1060,9 +1270,351 @@ var jsPsychModule = (function (exports) {
|
|
|
1060
1270
|
new TimeoutAPI(),
|
|
1061
1271
|
new MediaAPI(settings.use_webaudio, jsPsych.webaudio_context),
|
|
1062
1272
|
new HardwareAPI(),
|
|
1273
|
+
new SimulationAPI(),
|
|
1063
1274
|
].map((object) => autoBind(object)));
|
|
1064
1275
|
}
|
|
1065
1276
|
|
|
1277
|
+
var wordList = [
|
|
1278
|
+
// Borrowed from xkcd password generator which borrowed it from wherever
|
|
1279
|
+
"ability","able","aboard","about","above","accept","accident","according",
|
|
1280
|
+
"account","accurate","acres","across","act","action","active","activity",
|
|
1281
|
+
"actual","actually","add","addition","additional","adjective","adult","adventure",
|
|
1282
|
+
"advice","affect","afraid","after","afternoon","again","against","age",
|
|
1283
|
+
"ago","agree","ahead","aid","air","airplane","alike","alive",
|
|
1284
|
+
"all","allow","almost","alone","along","aloud","alphabet","already",
|
|
1285
|
+
"also","although","am","among","amount","ancient","angle","angry",
|
|
1286
|
+
"animal","announced","another","answer","ants","any","anybody","anyone",
|
|
1287
|
+
"anything","anyway","anywhere","apart","apartment","appearance","apple","applied",
|
|
1288
|
+
"appropriate","are","area","arm","army","around","arrange","arrangement",
|
|
1289
|
+
"arrive","arrow","art","article","as","aside","ask","asleep",
|
|
1290
|
+
"at","ate","atmosphere","atom","atomic","attached","attack","attempt",
|
|
1291
|
+
"attention","audience","author","automobile","available","average","avoid","aware",
|
|
1292
|
+
"away","baby","back","bad","badly","bag","balance","ball",
|
|
1293
|
+
"balloon","band","bank","bar","bare","bark","barn","base",
|
|
1294
|
+
"baseball","basic","basis","basket","bat","battle","be","bean",
|
|
1295
|
+
"bear","beat","beautiful","beauty","became","because","become","becoming",
|
|
1296
|
+
"bee","been","before","began","beginning","begun","behavior","behind",
|
|
1297
|
+
"being","believed","bell","belong","below","belt","bend","beneath",
|
|
1298
|
+
"bent","beside","best","bet","better","between","beyond","bicycle",
|
|
1299
|
+
"bigger","biggest","bill","birds","birth","birthday","bit","bite",
|
|
1300
|
+
"black","blank","blanket","blew","blind","block","blood","blow",
|
|
1301
|
+
"blue","board","boat","body","bone","book","border","born",
|
|
1302
|
+
"both","bottle","bottom","bound","bow","bowl","box","boy",
|
|
1303
|
+
"brain","branch","brass","brave","bread","break","breakfast","breath",
|
|
1304
|
+
"breathe","breathing","breeze","brick","bridge","brief","bright","bring",
|
|
1305
|
+
"broad","broke","broken","brother","brought","brown","brush","buffalo",
|
|
1306
|
+
"build","building","built","buried","burn","burst","bus","bush",
|
|
1307
|
+
"business","busy","but","butter","buy","by","cabin","cage",
|
|
1308
|
+
"cake","call","calm","came","camera","camp","can","canal",
|
|
1309
|
+
"cannot","cap","capital","captain","captured","car","carbon","card",
|
|
1310
|
+
"care","careful","carefully","carried","carry","case","cast","castle",
|
|
1311
|
+
"cat","catch","cattle","caught","cause","cave","cell","cent",
|
|
1312
|
+
"center","central","century","certain","certainly","chain","chair","chamber",
|
|
1313
|
+
"chance","change","changing","chapter","character","characteristic","charge","chart",
|
|
1314
|
+
"check","cheese","chemical","chest","chicken","chief","child","children",
|
|
1315
|
+
"choice","choose","chose","chosen","church","circle","circus","citizen",
|
|
1316
|
+
"city","class","classroom","claws","clay","clean","clear","clearly",
|
|
1317
|
+
"climate","climb","clock","close","closely","closer","cloth","clothes",
|
|
1318
|
+
"clothing","cloud","club","coach","coal","coast","coat","coffee",
|
|
1319
|
+
"cold","collect","college","colony","color","column","combination","combine",
|
|
1320
|
+
"come","comfortable","coming","command","common","community","company","compare",
|
|
1321
|
+
"compass","complete","completely","complex","composed","composition","compound","concerned",
|
|
1322
|
+
"condition","congress","connected","consider","consist","consonant","constantly","construction",
|
|
1323
|
+
"contain","continent","continued","contrast","control","conversation","cook","cookies",
|
|
1324
|
+
"cool","copper","copy","corn","corner","correct","correctly","cost",
|
|
1325
|
+
"cotton","could","count","country","couple","courage","course","court",
|
|
1326
|
+
"cover","cow","cowboy","crack","cream","create","creature","crew",
|
|
1327
|
+
"crop","cross","crowd","cry","cup","curious","current","curve",
|
|
1328
|
+
"customs","cut","cutting","daily","damage","dance","danger","dangerous",
|
|
1329
|
+
"dark","darkness","date","daughter","dawn","day","dead","deal",
|
|
1330
|
+
"dear","death","decide","declared","deep","deeply","deer","definition",
|
|
1331
|
+
"degree","depend","depth","describe","desert","design","desk","detail",
|
|
1332
|
+
"determine","develop","development","diagram","diameter","did","die","differ",
|
|
1333
|
+
"difference","different","difficult","difficulty","dig","dinner","direct","direction",
|
|
1334
|
+
"directly","dirt","dirty","disappear","discover","discovery","discuss","discussion",
|
|
1335
|
+
"disease","dish","distance","distant","divide","division","do","doctor",
|
|
1336
|
+
"does","dog","doing","doll","dollar","done","donkey","door",
|
|
1337
|
+
"dot","double","doubt","down","dozen","draw","drawn","dream",
|
|
1338
|
+
"dress","drew","dried","drink","drive","driven","driver","driving",
|
|
1339
|
+
"drop","dropped","drove","dry","duck","due","dug","dull",
|
|
1340
|
+
"during","dust","duty","each","eager","ear","earlier","early",
|
|
1341
|
+
"earn","earth","easier","easily","east","easy","eat","eaten",
|
|
1342
|
+
"edge","education","effect","effort","egg","eight","either","electric",
|
|
1343
|
+
"electricity","element","elephant","eleven","else","empty","end","enemy",
|
|
1344
|
+
"energy","engine","engineer","enjoy","enough","enter","entire","entirely",
|
|
1345
|
+
"environment","equal","equally","equator","equipment","escape","especially","essential",
|
|
1346
|
+
"establish","even","evening","event","eventually","ever","every","everybody",
|
|
1347
|
+
"everyone","everything","everywhere","evidence","exact","exactly","examine","example",
|
|
1348
|
+
"excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise",
|
|
1349
|
+
"exist","expect","experience","experiment","explain","explanation","explore","express",
|
|
1350
|
+
"expression","extra","eye","face","facing","fact","factor","factory",
|
|
1351
|
+
"failed","fair","fairly","fall","fallen","familiar","family","famous",
|
|
1352
|
+
"far","farm","farmer","farther","fast","fastened","faster","fat",
|
|
1353
|
+
"father","favorite","fear","feathers","feature","fed","feed","feel",
|
|
1354
|
+
"feet","fell","fellow","felt","fence","few","fewer","field",
|
|
1355
|
+
"fierce","fifteen","fifth","fifty","fight","fighting","figure","fill",
|
|
1356
|
+
"film","final","finally","find","fine","finest","finger","finish",
|
|
1357
|
+
"fire","fireplace","firm","first","fish","five","fix","flag",
|
|
1358
|
+
"flame","flat","flew","flies","flight","floating","floor","flow",
|
|
1359
|
+
"flower","fly","fog","folks","follow","food","foot","football",
|
|
1360
|
+
"for","force","foreign","forest","forget","forgot","forgotten","form",
|
|
1361
|
+
"former","fort","forth","forty","forward","fought","found","four",
|
|
1362
|
+
"fourth","fox","frame","free","freedom","frequently","fresh","friend",
|
|
1363
|
+
"friendly","frighten","frog","from","front","frozen","fruit","fuel",
|
|
1364
|
+
"full","fully","fun","function","funny","fur","furniture","further",
|
|
1365
|
+
"future","gain","game","garage","garden","gas","gasoline","gate",
|
|
1366
|
+
"gather","gave","general","generally","gentle","gently","get","getting",
|
|
1367
|
+
"giant","gift","girl","give","given","giving","glad","glass",
|
|
1368
|
+
"globe","go","goes","gold","golden","gone","good","goose",
|
|
1369
|
+
"got","government","grabbed","grade","gradually","grain","grandfather","grandmother",
|
|
1370
|
+
"graph","grass","gravity","gray","great","greater","greatest","greatly",
|
|
1371
|
+
"green","grew","ground","group","grow","grown","growth","guard",
|
|
1372
|
+
"guess","guide","gulf","gun","habit","had","hair","half",
|
|
1373
|
+
"halfway","hall","hand","handle","handsome","hang","happen","happened",
|
|
1374
|
+
"happily","happy","harbor","hard","harder","hardly","has","hat",
|
|
1375
|
+
"have","having","hay","he","headed","heading","health","heard",
|
|
1376
|
+
"hearing","heart","heat","heavy","height","held","hello","help",
|
|
1377
|
+
"helpful","her","herd","here","herself","hidden","hide","high",
|
|
1378
|
+
"higher","highest","highway","hill","him","himself","his","history",
|
|
1379
|
+
"hit","hold","hole","hollow","home","honor","hope","horn",
|
|
1380
|
+
"horse","hospital","hot","hour","house","how","however","huge",
|
|
1381
|
+
"human","hundred","hung","hungry","hunt","hunter","hurried","hurry",
|
|
1382
|
+
"hurt","husband","ice","idea","identity","if","ill","image",
|
|
1383
|
+
"imagine","immediately","importance","important","impossible","improve","in","inch",
|
|
1384
|
+
"include","including","income","increase","indeed","independent","indicate","individual",
|
|
1385
|
+
"industrial","industry","influence","information","inside","instance","instant","instead",
|
|
1386
|
+
"instrument","interest","interior","into","introduced","invented","involved","iron",
|
|
1387
|
+
"is","island","it","its","itself","jack","jar","jet",
|
|
1388
|
+
"job","join","joined","journey","joy","judge","jump","jungle",
|
|
1389
|
+
"just","keep","kept","key","kids","kill","kind","kitchen",
|
|
1390
|
+
"knew","knife","know","knowledge","known","label","labor","lack",
|
|
1391
|
+
"lady","laid","lake","lamp","land","language","large","larger",
|
|
1392
|
+
"largest","last","late","later","laugh","law","lay","layers",
|
|
1393
|
+
"lead","leader","leaf","learn","least","leather","leave","leaving",
|
|
1394
|
+
"led","left","leg","length","lesson","let","letter","level",
|
|
1395
|
+
"library","lie","life","lift","light","like","likely","limited",
|
|
1396
|
+
"line","lion","lips","liquid","list","listen","little","live",
|
|
1397
|
+
"living","load","local","locate","location","log","lonely","long",
|
|
1398
|
+
"longer","look","loose","lose","loss","lost","lot","loud",
|
|
1399
|
+
"love","lovely","low","lower","luck","lucky","lunch","lungs",
|
|
1400
|
+
"lying","machine","machinery","mad","made","magic","magnet","mail",
|
|
1401
|
+
"main","mainly","major","make","making","man","managed","manner",
|
|
1402
|
+
"manufacturing","many","map","mark","market","married","mass","massage",
|
|
1403
|
+
"master","material","mathematics","matter","may","maybe","me","meal",
|
|
1404
|
+
"mean","means","meant","measure","meat","medicine","meet","melted",
|
|
1405
|
+
"member","memory","men","mental","merely","met","metal","method",
|
|
1406
|
+
"mice","middle","might","mighty","mile","military","milk","mill",
|
|
1407
|
+
"mind","mine","minerals","minute","mirror","missing","mission","mistake",
|
|
1408
|
+
"mix","mixture","model","modern","molecular","moment","money","monkey",
|
|
1409
|
+
"month","mood","moon","more","morning","most","mostly","mother",
|
|
1410
|
+
"motion","motor","mountain","mouse","mouth","move","movement","movie",
|
|
1411
|
+
"moving","mud","muscle","music","musical","must","my","myself",
|
|
1412
|
+
"mysterious","nails","name","nation","national","native","natural","naturally",
|
|
1413
|
+
"nature","near","nearby","nearer","nearest","nearly","necessary","neck",
|
|
1414
|
+
"needed","needle","needs","negative","neighbor","neighborhood","nervous","nest",
|
|
1415
|
+
"never","new","news","newspaper","next","nice","night","nine",
|
|
1416
|
+
"no","nobody","nodded","noise","none","noon","nor","north",
|
|
1417
|
+
"nose","not","note","noted","nothing","notice","noun","now",
|
|
1418
|
+
"number","numeral","nuts","object","observe","obtain","occasionally","occur",
|
|
1419
|
+
"ocean","of","off","offer","office","officer","official","oil",
|
|
1420
|
+
"old","older","oldest","on","once","one","only","onto",
|
|
1421
|
+
"open","operation","opinion","opportunity","opposite","or","orange","orbit",
|
|
1422
|
+
"order","ordinary","organization","organized","origin","original","other","ought",
|
|
1423
|
+
"our","ourselves","out","outer","outline","outside","over","own",
|
|
1424
|
+
"owner","oxygen","pack","package","page","paid","pain","paint",
|
|
1425
|
+
"pair","palace","pale","pan","paper","paragraph","parallel","parent",
|
|
1426
|
+
"park","part","particles","particular","particularly","partly","parts","party",
|
|
1427
|
+
"pass","passage","past","path","pattern","pay","peace","pen",
|
|
1428
|
+
"pencil","people","per","percent","perfect","perfectly","perhaps","period",
|
|
1429
|
+
"person","personal","pet","phrase","physical","piano","pick","picture",
|
|
1430
|
+
"pictured","pie","piece","pig","pile","pilot","pine","pink",
|
|
1431
|
+
"pipe","pitch","place","plain","plan","plane","planet","planned",
|
|
1432
|
+
"planning","plant","plastic","plate","plates","play","pleasant","please",
|
|
1433
|
+
"pleasure","plenty","plural","plus","pocket","poem","poet","poetry",
|
|
1434
|
+
"point","pole","police","policeman","political","pond","pony","pool",
|
|
1435
|
+
"poor","popular","population","porch","port","position","positive","possible",
|
|
1436
|
+
"possibly","post","pot","potatoes","pound","pour","powder","power",
|
|
1437
|
+
"powerful","practical","practice","prepare","present","president","press","pressure",
|
|
1438
|
+
"pretty","prevent","previous","price","pride","primitive","principal","principle",
|
|
1439
|
+
"printed","private","prize","probably","problem","process","produce","product",
|
|
1440
|
+
"production","program","progress","promised","proper","properly","property","protection",
|
|
1441
|
+
"proud","prove","provide","public","pull","pupil","pure","purple",
|
|
1442
|
+
"purpose","push","put","putting","quarter","queen","question","quick",
|
|
1443
|
+
"quickly","quiet","quietly","quite","rabbit","race","radio","railroad",
|
|
1444
|
+
"rain","raise","ran","ranch","range","rapidly","rate","rather",
|
|
1445
|
+
"raw","rays","reach","read","reader","ready","real","realize",
|
|
1446
|
+
"rear","reason","recall","receive","recent","recently","recognize","record",
|
|
1447
|
+
"red","refer","refused","region","regular","related","relationship","religious",
|
|
1448
|
+
"remain","remarkable","remember","remove","repeat","replace","replied","report",
|
|
1449
|
+
"represent","require","research","respect","rest","result","return","review",
|
|
1450
|
+
"rhyme","rhythm","rice","rich","ride","riding","right","ring",
|
|
1451
|
+
"rise","rising","river","road","roar","rock","rocket","rocky",
|
|
1452
|
+
"rod","roll","roof","room","root","rope","rose","rough",
|
|
1453
|
+
"round","route","row","rubbed","rubber","rule","ruler","run",
|
|
1454
|
+
"running","rush","sad","saddle","safe","safety","said","sail",
|
|
1455
|
+
"sale","salmon","salt","same","sand","sang","sat","satellites",
|
|
1456
|
+
"satisfied","save","saved","saw","say","scale","scared","scene",
|
|
1457
|
+
"school","science","scientific","scientist","score","screen","sea","search",
|
|
1458
|
+
"season","seat","second","secret","section","see","seed","seeing",
|
|
1459
|
+
"seems","seen","seldom","select","selection","sell","send","sense",
|
|
1460
|
+
"sent","sentence","separate","series","serious","serve","service","sets",
|
|
1461
|
+
"setting","settle","settlers","seven","several","shade","shadow","shake",
|
|
1462
|
+
"shaking","shall","shallow","shape","share","sharp","she","sheep",
|
|
1463
|
+
"sheet","shelf","shells","shelter","shine","shinning","ship","shirt",
|
|
1464
|
+
"shoe","shoot","shop","shore","short","shorter","shot","should",
|
|
1465
|
+
"shoulder","shout","show","shown","shut","sick","sides","sight",
|
|
1466
|
+
"sign","signal","silence","silent","silk","silly","silver","similar",
|
|
1467
|
+
"simple","simplest","simply","since","sing","single","sink","sister",
|
|
1468
|
+
"sit","sitting","situation","six","size","skill","skin","sky",
|
|
1469
|
+
"slabs","slave","sleep","slept","slide","slight","slightly","slip",
|
|
1470
|
+
"slipped","slope","slow","slowly","small","smaller","smallest","smell",
|
|
1471
|
+
"smile","smoke","smooth","snake","snow","so","soap","social",
|
|
1472
|
+
"society","soft","softly","soil","solar","sold","soldier","solid",
|
|
1473
|
+
"solution","solve","some","somebody","somehow","someone","something","sometime",
|
|
1474
|
+
"somewhere","son","song","soon","sort","sound","source","south",
|
|
1475
|
+
"southern","space","speak","special","species","specific","speech","speed",
|
|
1476
|
+
"spell","spend","spent","spider","spin","spirit","spite","split",
|
|
1477
|
+
"spoken","sport","spread","spring","square","stage","stairs","stand",
|
|
1478
|
+
"standard","star","stared","start","state","statement","station","stay",
|
|
1479
|
+
"steady","steam","steel","steep","stems","step","stepped","stick",
|
|
1480
|
+
"stiff","still","stock","stomach","stone","stood","stop","stopped",
|
|
1481
|
+
"store","storm","story","stove","straight","strange","stranger","straw",
|
|
1482
|
+
"stream","street","strength","stretch","strike","string","strip","strong",
|
|
1483
|
+
"stronger","struck","structure","struggle","stuck","student","studied","studying",
|
|
1484
|
+
"subject","substance","success","successful","such","sudden","suddenly","sugar",
|
|
1485
|
+
"suggest","suit","sum","summer","sun","sunlight","supper","supply",
|
|
1486
|
+
"support","suppose","sure","surface","surprise","surrounded","swam","sweet",
|
|
1487
|
+
"swept","swim","swimming","swing","swung","syllable","symbol","system",
|
|
1488
|
+
"table","tail","take","taken","tales","talk","tall","tank",
|
|
1489
|
+
"tape","task","taste","taught","tax","tea","teach","teacher",
|
|
1490
|
+
"team","tears","teeth","telephone","television","tell","temperature","ten",
|
|
1491
|
+
"tent","term","terrible","test","than","thank","that","thee",
|
|
1492
|
+
"them","themselves","then","theory","there","therefore","these","they",
|
|
1493
|
+
"thick","thin","thing","think","third","thirty","this","those",
|
|
1494
|
+
"thou","though","thought","thousand","thread","three","threw","throat",
|
|
1495
|
+
"through","throughout","throw","thrown","thumb","thus","thy","tide",
|
|
1496
|
+
"tie","tight","tightly","till","time","tin","tiny","tip",
|
|
1497
|
+
"tired","title","to","tobacco","today","together","told","tomorrow",
|
|
1498
|
+
"tone","tongue","tonight","too","took","tool","top","topic",
|
|
1499
|
+
"torn","total","touch","toward","tower","town","toy","trace",
|
|
1500
|
+
"track","trade","traffic","trail","train","transportation","trap","travel",
|
|
1501
|
+
"treated","tree","triangle","tribe","trick","tried","trip","troops",
|
|
1502
|
+
"tropical","trouble","truck","trunk","truth","try","tube","tune",
|
|
1503
|
+
"turn","twelve","twenty","twice","two","type","typical","uncle",
|
|
1504
|
+
"under","underline","understanding","unhappy","union","unit","universe","unknown",
|
|
1505
|
+
"unless","until","unusual","up","upon","upper","upward","us",
|
|
1506
|
+
"use","useful","using","usual","usually","valley","valuable","value",
|
|
1507
|
+
"vapor","variety","various","vast","vegetable","verb","vertical","very",
|
|
1508
|
+
"vessels","victory","view","village","visit","visitor","voice","volume",
|
|
1509
|
+
"vote","vowel","voyage","wagon","wait","walk","wall","want",
|
|
1510
|
+
"war","warm","warn","was","wash","waste","watch","water",
|
|
1511
|
+
"wave","way","we","weak","wealth","wear","weather","week",
|
|
1512
|
+
"weigh","weight","welcome","well","went","were","west","western",
|
|
1513
|
+
"wet","whale","what","whatever","wheat","wheel","when","whenever",
|
|
1514
|
+
"where","wherever","whether","which","while","whispered","whistle","white",
|
|
1515
|
+
"who","whole","whom","whose","why","wide","widely","wife",
|
|
1516
|
+
"wild","will","willing","win","wind","window","wing","winter",
|
|
1517
|
+
"wire","wise","wish","with","within","without","wolf","women",
|
|
1518
|
+
"won","wonder","wonderful","wood","wooden","wool","word","wore",
|
|
1519
|
+
"work","worker","world","worried","worry","worse","worth","would",
|
|
1520
|
+
"wrapped","write","writer","writing","written","wrong","wrote","yard",
|
|
1521
|
+
"year","yellow","yes","yesterday","yet","you","young","younger",
|
|
1522
|
+
"your","yourself","youth","zero","zebra","zipper","zoo","zulu"
|
|
1523
|
+
];
|
|
1524
|
+
|
|
1525
|
+
function words(options) {
|
|
1526
|
+
|
|
1527
|
+
function word() {
|
|
1528
|
+
if (options && options.maxLength > 1) {
|
|
1529
|
+
return generateWordWithMaxLength();
|
|
1530
|
+
} else {
|
|
1531
|
+
return generateRandomWord();
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
function generateWordWithMaxLength() {
|
|
1536
|
+
var rightSize = false;
|
|
1537
|
+
var wordUsed;
|
|
1538
|
+
while (!rightSize) {
|
|
1539
|
+
wordUsed = generateRandomWord();
|
|
1540
|
+
if(wordUsed.length <= options.maxLength) {
|
|
1541
|
+
rightSize = true;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
}
|
|
1545
|
+
return wordUsed;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
function generateRandomWord() {
|
|
1549
|
+
return wordList[randInt(wordList.length)];
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
function randInt(lessThan) {
|
|
1553
|
+
return Math.floor(Math.random() * lessThan);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// No arguments = generate one word
|
|
1557
|
+
if (typeof(options) === 'undefined') {
|
|
1558
|
+
return word();
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// Just a number = return that many words
|
|
1562
|
+
if (typeof(options) === 'number') {
|
|
1563
|
+
options = { exactly: options };
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
// options supported: exactly, min, max, join
|
|
1567
|
+
if (options.exactly) {
|
|
1568
|
+
options.min = options.exactly;
|
|
1569
|
+
options.max = options.exactly;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// not a number = one word par string
|
|
1573
|
+
if (typeof(options.wordsPerString) !== 'number') {
|
|
1574
|
+
options.wordsPerString = 1;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
//not a function = returns the raw word
|
|
1578
|
+
if (typeof(options.formatter) !== 'function') {
|
|
1579
|
+
options.formatter = (word) => word;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
//not a string = separator is a space
|
|
1583
|
+
if (typeof(options.separator) !== 'string') {
|
|
1584
|
+
options.separator = ' ';
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
var total = options.min + randInt(options.max + 1 - options.min);
|
|
1588
|
+
var results = [];
|
|
1589
|
+
var token = '';
|
|
1590
|
+
var relativeIndex = 0;
|
|
1591
|
+
|
|
1592
|
+
for (var i = 0; (i < total * options.wordsPerString); i++) {
|
|
1593
|
+
if (relativeIndex === options.wordsPerString - 1) {
|
|
1594
|
+
token += options.formatter(word(), relativeIndex);
|
|
1595
|
+
}
|
|
1596
|
+
else {
|
|
1597
|
+
token += options.formatter(word(), relativeIndex) + options.separator;
|
|
1598
|
+
}
|
|
1599
|
+
relativeIndex++;
|
|
1600
|
+
if ((i + 1) % options.wordsPerString === 0) {
|
|
1601
|
+
results.push(token);
|
|
1602
|
+
token = '';
|
|
1603
|
+
relativeIndex = 0;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
}
|
|
1607
|
+
if (typeof options.join === 'string') {
|
|
1608
|
+
results = results.join(options.join);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
return results;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
var randomWords$1 = words;
|
|
1615
|
+
// Export the word list as it is often useful
|
|
1616
|
+
words.wordList = wordList;
|
|
1617
|
+
|
|
1066
1618
|
function repeat(array, repetitions, unpack = false) {
|
|
1067
1619
|
const arr_isArray = Array.isArray(array);
|
|
1068
1620
|
const rep_isArray = Array.isArray(repetitions);
|
|
@@ -1272,6 +1824,64 @@ var jsPsychModule = (function (exports) {
|
|
|
1272
1824
|
}
|
|
1273
1825
|
return result;
|
|
1274
1826
|
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Generate a random integer from `lower` to `upper`, inclusive of both end points.
|
|
1829
|
+
* @param lower The lowest value it is possible to generate
|
|
1830
|
+
* @param upper The highest value it is possible to generate
|
|
1831
|
+
* @returns A random integer
|
|
1832
|
+
*/
|
|
1833
|
+
function randomInt(lower, upper) {
|
|
1834
|
+
if (upper < lower) {
|
|
1835
|
+
throw new Error("Upper boundary must be less than or equal to lower boundary");
|
|
1836
|
+
}
|
|
1837
|
+
return lower + Math.floor(Math.random() * (upper - lower + 1));
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Generates a random sample from a Bernoulli distribution.
|
|
1841
|
+
* @param p The probability of sampling 1.
|
|
1842
|
+
* @returns 0, with probability 1-p, or 1, with probability p.
|
|
1843
|
+
*/
|
|
1844
|
+
function sampleBernoulli(p) {
|
|
1845
|
+
return Math.random() <= p ? 1 : 0;
|
|
1846
|
+
}
|
|
1847
|
+
function sampleNormal(mean, standard_deviation) {
|
|
1848
|
+
return randn_bm() * standard_deviation + mean;
|
|
1849
|
+
}
|
|
1850
|
+
function sampleExponential(rate) {
|
|
1851
|
+
return -Math.log(Math.random()) / rate;
|
|
1852
|
+
}
|
|
1853
|
+
function sampleExGaussian(mean, standard_deviation, rate, positive = false) {
|
|
1854
|
+
let s = sampleNormal(mean, standard_deviation) + sampleExponential(rate);
|
|
1855
|
+
if (positive) {
|
|
1856
|
+
while (s <= 0) {
|
|
1857
|
+
s = sampleNormal(mean, standard_deviation) + sampleExponential(rate);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return s;
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Generate one or more random words.
|
|
1864
|
+
*
|
|
1865
|
+
* This is a wrapper function for the {@link https://www.npmjs.com/package/random-words `random-words` npm package}.
|
|
1866
|
+
*
|
|
1867
|
+
* @param opts An object with optional properties `min`, `max`, `exactly`,
|
|
1868
|
+
* `join`, `maxLength`, `wordsPerString`, `separator`, and `formatter`.
|
|
1869
|
+
*
|
|
1870
|
+
* @returns An array of words or a single string, depending on parameter choices.
|
|
1871
|
+
*/
|
|
1872
|
+
function randomWords(opts) {
|
|
1873
|
+
return randomWords$1(opts);
|
|
1874
|
+
}
|
|
1875
|
+
// Box-Muller transformation for a random sample from normal distribution with mean = 0, std = 1
|
|
1876
|
+
// https://stackoverflow.com/a/36481059/3726673
|
|
1877
|
+
function randn_bm() {
|
|
1878
|
+
var u = 0, v = 0;
|
|
1879
|
+
while (u === 0)
|
|
1880
|
+
u = Math.random(); //Converting [0,1) to (0,1)
|
|
1881
|
+
while (v === 0)
|
|
1882
|
+
v = Math.random();
|
|
1883
|
+
return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
|
|
1884
|
+
}
|
|
1275
1885
|
function unpackArray(array) {
|
|
1276
1886
|
const out = {};
|
|
1277
1887
|
for (const x of array) {
|
|
@@ -1294,7 +1904,13 @@ var jsPsychModule = (function (exports) {
|
|
|
1294
1904
|
sampleWithoutReplacement: sampleWithoutReplacement,
|
|
1295
1905
|
sampleWithReplacement: sampleWithReplacement,
|
|
1296
1906
|
factorial: factorial,
|
|
1297
|
-
randomID: randomID
|
|
1907
|
+
randomID: randomID,
|
|
1908
|
+
randomInt: randomInt,
|
|
1909
|
+
sampleBernoulli: sampleBernoulli,
|
|
1910
|
+
sampleNormal: sampleNormal,
|
|
1911
|
+
sampleExponential: sampleExponential,
|
|
1912
|
+
sampleExGaussian: sampleExGaussian,
|
|
1913
|
+
randomWords: randomWords
|
|
1298
1914
|
});
|
|
1299
1915
|
|
|
1300
1916
|
/**
|
|
@@ -1841,6 +2457,10 @@ var jsPsychModule = (function (exports) {
|
|
|
1841
2457
|
* is the page retrieved directly via file:// protocol (true) or hosted on a server (false)?
|
|
1842
2458
|
*/
|
|
1843
2459
|
this.file_protocol = false;
|
|
2460
|
+
/**
|
|
2461
|
+
* is the experiment running in `simulate()` mode
|
|
2462
|
+
*/
|
|
2463
|
+
this.simulation_mode = null;
|
|
1844
2464
|
// storing a single webaudio context to prevent problems with multiple inits
|
|
1845
2465
|
// of jsPsych
|
|
1846
2466
|
this.webaudio_context = null;
|
|
@@ -1910,6 +2530,13 @@ var jsPsychModule = (function (exports) {
|
|
|
1910
2530
|
yield this.finished;
|
|
1911
2531
|
});
|
|
1912
2532
|
}
|
|
2533
|
+
simulate(timeline, simulation_mode, simulation_options = {}) {
|
|
2534
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2535
|
+
this.simulation_mode = simulation_mode;
|
|
2536
|
+
this.simulation_options = simulation_options;
|
|
2537
|
+
yield this.run(timeline);
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
1913
2540
|
getProgress() {
|
|
1914
2541
|
return {
|
|
1915
2542
|
total_trials: typeof this.timeline === "undefined" ? undefined : this.timeline.length(),
|
|
@@ -2012,12 +2639,12 @@ var jsPsychModule = (function (exports) {
|
|
|
2012
2639
|
}
|
|
2013
2640
|
}
|
|
2014
2641
|
}
|
|
2015
|
-
endExperiment(end_message) {
|
|
2642
|
+
endExperiment(end_message = "", data = {}) {
|
|
2016
2643
|
this.timeline.end_message = end_message;
|
|
2017
2644
|
this.timeline.end();
|
|
2018
2645
|
this.pluginAPI.cancelAllKeyboardResponses();
|
|
2019
2646
|
this.pluginAPI.clearAllTimeouts();
|
|
2020
|
-
this.finishTrial();
|
|
2647
|
+
this.finishTrial(data);
|
|
2021
2648
|
}
|
|
2022
2649
|
endCurrentTimeline() {
|
|
2023
2650
|
this.timeline.endActiveNode();
|
|
@@ -2195,6 +2822,9 @@ var jsPsychModule = (function (exports) {
|
|
|
2195
2822
|
this.current_trial_finished = false;
|
|
2196
2823
|
// process all timeline variables for this trial
|
|
2197
2824
|
this.evaluateTimelineVariables(trial);
|
|
2825
|
+
if (typeof trial.type === "string") {
|
|
2826
|
+
throw new MigrationError("A string was provided as the trial's `type` parameter. Since jsPsych v7, the `type` parameter needs to be a plugin object.");
|
|
2827
|
+
}
|
|
2198
2828
|
// instantiate the plugin for this trial
|
|
2199
2829
|
trial.type = Object.assign(Object.assign({}, autoBind(new trial.type(this))), { info: trial.type.info });
|
|
2200
2830
|
// evaluate variables that are functions
|
|
@@ -2240,10 +2870,53 @@ var jsPsychModule = (function (exports) {
|
|
|
2240
2870
|
}
|
|
2241
2871
|
}
|
|
2242
2872
|
};
|
|
2243
|
-
|
|
2873
|
+
let trial_complete;
|
|
2874
|
+
if (!this.simulation_mode) {
|
|
2875
|
+
trial_complete = trial.type.trial(this.DOM_target, trial, load_callback);
|
|
2876
|
+
}
|
|
2877
|
+
if (this.simulation_mode) {
|
|
2878
|
+
// check if the trial supports simulation
|
|
2879
|
+
if (trial.type.simulate) {
|
|
2880
|
+
let trial_sim_opts;
|
|
2881
|
+
if (!trial.simulation_options) {
|
|
2882
|
+
trial_sim_opts = this.simulation_options.default;
|
|
2883
|
+
}
|
|
2884
|
+
if (trial.simulation_options) {
|
|
2885
|
+
if (typeof trial.simulation_options == "string") {
|
|
2886
|
+
if (this.simulation_options[trial.simulation_options]) {
|
|
2887
|
+
trial_sim_opts = this.simulation_options[trial.simulation_options];
|
|
2888
|
+
}
|
|
2889
|
+
else if (this.simulation_options.default) {
|
|
2890
|
+
console.log(`No matching simulation options found for "${trial.simulation_options}". Using "default" options.`);
|
|
2891
|
+
trial_sim_opts = this.simulation_options.default;
|
|
2892
|
+
}
|
|
2893
|
+
else {
|
|
2894
|
+
console.log(`No matching simulation options found for "${trial.simulation_options}" and no "default" options provided. Using the default values provided by the plugin.`);
|
|
2895
|
+
trial_sim_opts = {};
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
else {
|
|
2899
|
+
trial_sim_opts = trial.simulation_options;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
trial_sim_opts = this.utils.deepCopy(trial_sim_opts);
|
|
2903
|
+
trial_sim_opts = this.replaceFunctionsWithValues(trial_sim_opts, null);
|
|
2904
|
+
if ((trial_sim_opts === null || trial_sim_opts === void 0 ? void 0 : trial_sim_opts.simulate) === false) {
|
|
2905
|
+
trial_complete = trial.type.trial(this.DOM_target, trial, load_callback);
|
|
2906
|
+
}
|
|
2907
|
+
else {
|
|
2908
|
+
trial_complete = trial.type.simulate(trial, (trial_sim_opts === null || trial_sim_opts === void 0 ? void 0 : trial_sim_opts.mode) || this.simulation_mode, trial_sim_opts, load_callback);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
else {
|
|
2912
|
+
// trial doesn't have a simulate method, so just run as usual
|
|
2913
|
+
trial_complete = trial.type.trial(this.DOM_target, trial, load_callback);
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2244
2916
|
// see if trial_complete is a Promise by looking for .then() function
|
|
2245
2917
|
const is_promise = trial_complete && typeof trial_complete.then == "function";
|
|
2246
|
-
|
|
2918
|
+
// in simulation mode we let the simulate function call the load_callback always.
|
|
2919
|
+
if (!is_promise && !this.simulation_mode) {
|
|
2247
2920
|
load_callback();
|
|
2248
2921
|
}
|
|
2249
2922
|
// done with callbacks
|
|
@@ -2369,6 +3042,9 @@ var jsPsychModule = (function (exports) {
|
|
|
2369
3042
|
}
|
|
2370
3043
|
checkExclusions(exclusions) {
|
|
2371
3044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3045
|
+
if (exclusions.min_width || exclusions.min_height || exclusions.audio) {
|
|
3046
|
+
console.warn("The exclusions option in `initJsPsych()` is deprecated and will be removed in a future version. We recommend using the browser-check plugin instead. See https://www.jspsych.org/latest/plugins/browser-check/.");
|
|
3047
|
+
}
|
|
2372
3048
|
// MINIMUM SIZE
|
|
2373
3049
|
if (exclusions.min_width || exclusions.min_height) {
|
|
2374
3050
|
const mw = exclusions.min_width || 0;
|
|
@@ -2449,7 +3125,30 @@ var jsPsychModule = (function (exports) {
|
|
|
2449
3125
|
* @returns A new JsPsych instance
|
|
2450
3126
|
*/
|
|
2451
3127
|
function initJsPsych(options) {
|
|
2452
|
-
|
|
3128
|
+
const jsPsych = new JsPsych(options);
|
|
3129
|
+
// Handle invocations of non-existent v6 methods with migration errors
|
|
3130
|
+
const migrationMessages = {
|
|
3131
|
+
init: "`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.",
|
|
3132
|
+
ALL_KEYS: 'jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.',
|
|
3133
|
+
NO_KEYS: 'jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.',
|
|
3134
|
+
// Getter functions that were renamed
|
|
3135
|
+
currentTimelineNodeID: "`currentTimelineNodeID()` was renamed to `getCurrentTimelineNodeID()` in jsPsych v7.",
|
|
3136
|
+
progress: "`progress()` was renamed to `getProgress()` in jsPsych v7.",
|
|
3137
|
+
startTime: "`startTime()` was renamed to `getStartTime()` in jsPsych v7.",
|
|
3138
|
+
totalTime: "`totalTime()` was renamed to `getTotalTime()` in jsPsych v7.",
|
|
3139
|
+
currentTrial: "`currentTrial()` was renamed to `getCurrentTrial()` in jsPsych v7.",
|
|
3140
|
+
initSettings: "`initSettings()` was renamed to `getInitSettings()` in jsPsych v7.",
|
|
3141
|
+
allTimelineVariables: "`allTimelineVariables()` was renamed to `getAllTimelineVariables()` in jsPsych v7.",
|
|
3142
|
+
};
|
|
3143
|
+
Object.defineProperties(jsPsych, Object.fromEntries(Object.entries(migrationMessages).map(([key, message]) => [
|
|
3144
|
+
key,
|
|
3145
|
+
{
|
|
3146
|
+
get() {
|
|
3147
|
+
throw new MigrationError(message);
|
|
3148
|
+
},
|
|
3149
|
+
},
|
|
3150
|
+
])));
|
|
3151
|
+
return jsPsych;
|
|
2453
3152
|
}
|
|
2454
3153
|
|
|
2455
3154
|
exports.JsPsych = JsPsych;
|