jspsych 8.0.0 → 8.0.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.cjs CHANGED
@@ -6,7 +6,7 @@ var seedrandom = require('seedrandom/lib/alea');
6
6
 
7
7
  var _package = {
8
8
  name: "jspsych",
9
- version: "8.0.0",
9
+ version: "8.0.2",
10
10
  description: "Behavioral experiments in a browser",
11
11
  type: "module",
12
12
  main: "dist/index.cjs",
@@ -88,9 +88,26 @@ class ExtensionManager {
88
88
  }
89
89
  async initializeExtensions() {
90
90
  await Promise.all(
91
- this.extensionsConfiguration.map(
92
- ({ type, params = {} }) => this.getExtensionInstanceByClass(type).initialize(params)
93
- )
91
+ this.extensionsConfiguration.map(({ type, params = {} }) => {
92
+ this.getExtensionInstanceByClass(type).initialize(params);
93
+ const extensionInfo = type["info"];
94
+ if (!("version" in extensionInfo) && !("data" in extensionInfo)) {
95
+ console.warn(
96
+ extensionInfo["name"],
97
+ "is missing the 'version' and 'data' fields. Please update extension as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."
98
+ );
99
+ } else if (!("version" in extensionInfo)) {
100
+ console.warn(
101
+ extensionInfo["name"],
102
+ "is missing the 'version' field. Please update extension as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."
103
+ );
104
+ } else if (!("data" in extensionInfo)) {
105
+ console.warn(
106
+ extensionInfo["name"],
107
+ "is missing the 'data' field. Please update extension as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."
108
+ );
109
+ }
110
+ })
94
111
  );
95
112
  }
96
113
  onStart(trialExtensionsConfiguration = []) {
@@ -109,11 +126,11 @@ class ExtensionManager {
109
126
  ({ type, params }) => Promise.resolve(this.getExtensionInstanceByClass(type)?.on_finish(params))
110
127
  )
111
128
  );
112
- const extensionInfo = trialExtensionsConfiguration.length ? {
113
- extension_type: results.map((result) => result.extension_type),
114
- extension_version: results.map((result) => result.extension_version)
129
+ const extensionInfos = trialExtensionsConfiguration.length ? {
130
+ extension_type: trialExtensionsConfiguration.map(({ type }) => type["info"].name),
131
+ extension_version: trialExtensionsConfiguration.map(({ type }) => type["info"].version)
115
132
  } : {};
116
- results.push(extensionInfo);
133
+ results.unshift(extensionInfos);
117
134
  return Object.assign({}, ...results);
118
135
  }
119
136
  }
@@ -599,7 +616,7 @@ class KeyboardListenerAPI {
599
616
  }
600
617
  }
601
618
  rootKeydownListener(e) {
602
- for (const listener of Array.from(this.listeners)) {
619
+ for (const listener of [...this.listeners]) {
603
620
  listener(e);
604
621
  }
605
622
  this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key));