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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jspsych",
3
- "version": "8.0.0",
3
+ "version": "8.0.2",
4
4
  "description": "Behavioral experiments in a browser",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -102,8 +102,6 @@ describe("ExtensionManager", () => {
102
102
 
103
103
  const onFinishCallback = jest.mocked(manager.extensions.test.on_finish);
104
104
  onFinishCallback.mockReturnValue({
105
- extension_type: "test",
106
- extension_version: "1.0",
107
105
  extension: "result",
108
106
  });
109
107
 
@@ -115,7 +113,7 @@ describe("ExtensionManager", () => {
115
113
  expect(onFinishCallback).toHaveBeenCalledWith({ my: "option" });
116
114
  expect(results).toEqual({
117
115
  extension_type: ["test"],
118
- extension_version: ["1.0"],
116
+ extension_version: ["0.0.1"],
119
117
  extension: "result",
120
118
  });
121
119
  });
@@ -40,9 +40,28 @@ export class ExtensionManager {
40
40
 
41
41
  public async initializeExtensions() {
42
42
  await Promise.all(
43
- this.extensionsConfiguration.map(({ type, params = {} }) =>
44
- this.getExtensionInstanceByClass(type).initialize(params)
45
- )
43
+ this.extensionsConfiguration.map(({ type, params = {} }) => {
44
+ this.getExtensionInstanceByClass(type).initialize(params);
45
+
46
+ const extensionInfo = type["info"] as JsPsychExtensionInfo;
47
+
48
+ if (!("version" in extensionInfo) && !("data" in extensionInfo)) {
49
+ console.warn(
50
+ extensionInfo["name"],
51
+ "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."
52
+ );
53
+ } else if (!("version" in extensionInfo)) {
54
+ console.warn(
55
+ extensionInfo["name"],
56
+ "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."
57
+ );
58
+ } else if (!("data" in extensionInfo)) {
59
+ console.warn(
60
+ extensionInfo["name"],
61
+ "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."
62
+ );
63
+ }
64
+ })
46
65
  );
47
66
  }
48
67
 
@@ -67,14 +86,14 @@ export class ExtensionManager {
67
86
  )
68
87
  );
69
88
 
70
- const extensionInfo = trialExtensionsConfiguration.length
89
+ const extensionInfos = trialExtensionsConfiguration.length
71
90
  ? {
72
- extension_type: results.map((result) => result.extension_type),
73
- extension_version: results.map((result) => result.extension_version),
91
+ extension_type: trialExtensionsConfiguration.map(({ type }) => type["info"].name),
92
+ extension_version: trialExtensionsConfiguration.map(({ type }) => type["info"].version),
74
93
  }
75
94
  : {};
76
95
 
77
- results.push(extensionInfo);
96
+ results.unshift(extensionInfos);
78
97
 
79
98
  return Object.assign({}, ...results);
80
99
  }
@@ -48,7 +48,7 @@ export class KeyboardListenerAPI {
48
48
  private rootKeydownListener(e: KeyboardEvent) {
49
49
  // Iterate over a static copy of the listeners set because listeners might add other listeners
50
50
  // that we do not want to be included in the loop
51
- for (const listener of Array.from(this.listeners)) {
51
+ for (const listener of [...this.listeners]) {
52
52
  listener(e);
53
53
  }
54
54
  this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key));