jspsych 8.2.2 → 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/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ type ParameterInfo = ({
50
50
  array?: boolean;
51
51
  pretty_name?: string;
52
52
  default?: any;
53
+ options?: any;
53
54
  };
54
55
  type ParameterInfos = Record<string, ParameterInfo>;
55
56
  type InferredParameter<I extends ParameterInfo> = I["array"] extends true ? Array<ParameterTypeMap[I["type"]]> : ParameterTypeMap[I["type"]];
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.2";
5
+ var version = "8.2.3";
6
6
 
7
7
  class ExtensionManager {
8
8
  constructor(dependencies, extensionsConfiguration) {
@@ -2064,6 +2064,73 @@ class Trial extends TimelineNode {
2064
2064
  }
2065
2065
  }
2066
2066
  });
2067
+ if (!parameterConfig.array && parameterValue !== null) {
2068
+ switch (parameterConfig.type) {
2069
+ case ParameterType.BOOL:
2070
+ if (typeof parameterValue !== "boolean") {
2071
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2072
+ console.warn(
2073
+ `A non-boolean value (\`${parameterValue}\`) was provided for the boolean parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
2074
+ );
2075
+ }
2076
+ break;
2077
+ // @ts-ignore falls through
2078
+ case ParameterType.KEYS:
2079
+ if (Array.isArray(parameterValue)) break;
2080
+ case ParameterType.STRING:
2081
+ case ParameterType.HTML_STRING:
2082
+ case ParameterType.KEY:
2083
+ case ParameterType.AUDIO:
2084
+ case ParameterType.VIDEO:
2085
+ case ParameterType.IMAGE:
2086
+ if (typeof parameterValue !== "string") {
2087
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2088
+ console.warn(
2089
+ `A non-string value (\`${parameterValue}\`) was provided for the parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
2090
+ );
2091
+ }
2092
+ break;
2093
+ case ParameterType.FLOAT:
2094
+ case ParameterType.INT:
2095
+ if (typeof parameterValue !== "number") {
2096
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2097
+ console.warn(
2098
+ `A non-numeric value (\`${parameterValue}\`) was provided for the numeric parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
2099
+ );
2100
+ }
2101
+ break;
2102
+ case ParameterType.FUNCTION:
2103
+ if (typeof parameterValue !== "function") {
2104
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2105
+ console.warn(
2106
+ `A non-function value (\`${parameterValue}\`) was provided for the function parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
2107
+ );
2108
+ }
2109
+ break;
2110
+ case ParameterType.SELECT:
2111
+ if (!parameterConfig.options) {
2112
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2113
+ console.warn(
2114
+ `The "options" array is required for the "select" parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin.`
2115
+ );
2116
+ }
2117
+ }
2118
+ if (parameterConfig.type === ParameterType.INT && parameterValue % 1 !== 0) {
2119
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2120
+ console.warn(
2121
+ `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.`
2122
+ );
2123
+ parameterValue = Math.trunc(parameterValue);
2124
+ }
2125
+ }
2126
+ if (parameterConfig.type === ParameterType.SELECT) {
2127
+ if (!parameterConfig.options.includes(parameterValue)) {
2128
+ const parameterPathString = parameterPathArrayToString(parameterPath);
2129
+ console.warn(
2130
+ `The value "${parameterValue}" is not a valid option for the parameter "${parameterPathString}" in the "${this.pluginInfo.name}" plugin. Valid options are: ${parameterConfig.options.join(", ")}.`
2131
+ );
2132
+ }
2133
+ }
2067
2134
  if (parameterConfig.array && !Array.isArray(parameterValue)) {
2068
2135
  const parameterPathString = parameterPathArrayToString(parameterPath);
2069
2136
  throw new Error(