jspsych 8.0.0 → 8.0.1
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.browser.js +26 -9
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +5 -5
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ExtensionManager.spec.ts +1 -3
- package/src/ExtensionManager.ts +26 -7
package/package.json
CHANGED
|
@@ -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: ["
|
|
116
|
+
extension_version: ["0.0.1"],
|
|
119
117
|
extension: "result",
|
|
120
118
|
});
|
|
121
119
|
});
|
package/src/ExtensionManager.ts
CHANGED
|
@@ -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
|
|
89
|
+
const extensionInfos = trialExtensionsConfiguration.length
|
|
71
90
|
? {
|
|
72
|
-
extension_type:
|
|
73
|
-
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.
|
|
96
|
+
results.unshift(extensionInfos);
|
|
78
97
|
|
|
79
98
|
return Object.assign({}, ...results);
|
|
80
99
|
}
|