jspsych 8.2.1 → 8.2.3
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 +95 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +7 -7
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +94 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +94 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/modules/plugin-api/MediaAPI.ts +28 -1
- package/src/modules/plugins.ts +1 -0
- package/src/timeline/Trial.spec.ts +105 -1
- package/src/timeline/Trial.ts +78 -0
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var autoBind = require('auto-bind');
|
|
|
4
4
|
var rw = require('random-words');
|
|
5
5
|
var seedrandom = require('seedrandom/lib/alea.js');
|
|
6
6
|
|
|
7
|
-
var version = "8.2.
|
|
7
|
+
var version = "8.2.3";
|
|
8
8
|
|
|
9
9
|
class ExtensionManager {
|
|
10
10
|
constructor(dependencies, extensionsConfiguration) {
|
|
@@ -969,10 +969,35 @@ class MediaAPI {
|
|
|
969
969
|
return this.microphone_recorder;
|
|
970
970
|
}
|
|
971
971
|
initializeCameraRecorder(stream, opts) {
|
|
972
|
+
let mimeType = this.getCompatibleMimeType() || "video/webm";
|
|
973
|
+
const recorderOptions = {
|
|
974
|
+
...opts,
|
|
975
|
+
mimeType
|
|
976
|
+
};
|
|
972
977
|
this.camera_stream = stream;
|
|
973
|
-
const recorder = new MediaRecorder(stream,
|
|
978
|
+
const recorder = new MediaRecorder(stream, recorderOptions);
|
|
974
979
|
this.camera_recorder = recorder;
|
|
975
980
|
}
|
|
981
|
+
// mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
|
|
982
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
983
|
+
getCompatibleMimeType() {
|
|
984
|
+
const types = [
|
|
985
|
+
// chrome firefox edge
|
|
986
|
+
"video/webm;codecs=vp9,opus",
|
|
987
|
+
"video/webm;codecs=vp8,opus",
|
|
988
|
+
// general
|
|
989
|
+
"video/mp4;codecs=avc1.42E01E,mp4a.40.2",
|
|
990
|
+
// safari
|
|
991
|
+
"video/mp4;codecs=h264,aac",
|
|
992
|
+
"video/mp4;codecs=hevc,aac"
|
|
993
|
+
];
|
|
994
|
+
for (const mimeType of types) {
|
|
995
|
+
if (MediaRecorder.isTypeSupported(mimeType)) {
|
|
996
|
+
return mimeType;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
976
1001
|
getCameraStream() {
|
|
977
1002
|
return this.camera_stream;
|
|
978
1003
|
}
|
|
@@ -2041,6 +2066,73 @@ class Trial extends TimelineNode {
|
|
|
2041
2066
|
}
|
|
2042
2067
|
}
|
|
2043
2068
|
});
|
|
2069
|
+
if (!parameterConfig.array && parameterValue !== null) {
|
|
2070
|
+
switch (parameterConfig.type) {
|
|
2071
|
+
case ParameterType.BOOL:
|
|
2072
|
+
if (typeof parameterValue !== "boolean") {
|
|
2073
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2074
|
+
console.warn(
|
|
2075
|
+
`A non-boolean value (\`${parameterValue}\`) was provided for the boolean parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2078
|
+
break;
|
|
2079
|
+
// @ts-ignore falls through
|
|
2080
|
+
case ParameterType.KEYS:
|
|
2081
|
+
if (Array.isArray(parameterValue)) break;
|
|
2082
|
+
case ParameterType.STRING:
|
|
2083
|
+
case ParameterType.HTML_STRING:
|
|
2084
|
+
case ParameterType.KEY:
|
|
2085
|
+
case ParameterType.AUDIO:
|
|
2086
|
+
case ParameterType.VIDEO:
|
|
2087
|
+
case ParameterType.IMAGE:
|
|
2088
|
+
if (typeof parameterValue !== "string") {
|
|
2089
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2090
|
+
console.warn(
|
|
2091
|
+
`A non-string value (\`${parameterValue}\`) was provided for the parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
break;
|
|
2095
|
+
case ParameterType.FLOAT:
|
|
2096
|
+
case ParameterType.INT:
|
|
2097
|
+
if (typeof parameterValue !== "number") {
|
|
2098
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2099
|
+
console.warn(
|
|
2100
|
+
`A non-numeric value (\`${parameterValue}\`) was provided for the numeric parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
break;
|
|
2104
|
+
case ParameterType.FUNCTION:
|
|
2105
|
+
if (typeof parameterValue !== "function") {
|
|
2106
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2107
|
+
console.warn(
|
|
2108
|
+
`A non-function value (\`${parameterValue}\`) was provided for the function parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
|
|
2109
|
+
);
|
|
2110
|
+
}
|
|
2111
|
+
break;
|
|
2112
|
+
case ParameterType.SELECT:
|
|
2113
|
+
if (!parameterConfig.options) {
|
|
2114
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2115
|
+
console.warn(
|
|
2116
|
+
`The "options" array is required for the "select" parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
if (parameterConfig.type === ParameterType.INT && parameterValue % 1 !== 0) {
|
|
2121
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2122
|
+
console.warn(
|
|
2123
|
+
`A float value (\`${parameterValue}\`) was provided for the integer parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin. The value will be truncated to an integer.`
|
|
2124
|
+
);
|
|
2125
|
+
parameterValue = Math.trunc(parameterValue);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
if (parameterConfig.type === ParameterType.SELECT) {
|
|
2129
|
+
if (!parameterConfig.options.includes(parameterValue)) {
|
|
2130
|
+
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2131
|
+
console.warn(
|
|
2132
|
+
`The value "${parameterValue}" is not a valid option for the parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin. Valid options are: ${parameterConfig.options.join(", ")}.`
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2044
2136
|
if (parameterConfig.array && !Array.isArray(parameterValue)) {
|
|
2045
2137
|
const parameterPathString = parameterPathArrayToString(parameterPath);
|
|
2046
2138
|
throw new Error(
|