diff --git a/templates/extension-template-js/index.js b/templates/extension-template-js/index.js index dc206f80..fb7c44ac 100644 --- a/templates/extension-template-js/index.js +++ b/templates/extension-template-js/index.js @@ -26,12 +26,24 @@ var _globalName_ = (function (jspsych) { on_finish(params) { return { - data_property: "data_value", + data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const. + data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const. }; } } ExtensionNameExtension.info = { name: "{name}", + version: "1.0.0", // When working in a Javascript environment with no build, you will need to manually put set the version information. This is used for metadata purposes and publishing. + data: { + /** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data1: { + type: ParameterType.INT, + }, + /** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data2: { + type: ParameterType.STRING, + }, + }, }; return ExtensionNameExtension; diff --git a/templates/extension-template-ts/src/index.ts b/templates/extension-template-ts/src/index.ts index 5e38a1fd..4abd5b00 100644 --- a/templates/extension-template-ts/src/index.ts +++ b/templates/extension-template-ts/src/index.ts @@ -1,4 +1,6 @@ -import { JsPsych, JsPsychExtension, JsPsychExtensionInfo } from "jspsych"; +import { JsPsych, JsPsychExtension, JsPsychExtensionInfo, ParameterType } from "jspsych"; + +import { version } from "../package.json"; interface InitializeParameters {} @@ -19,6 +21,17 @@ interface OnFinishParameters {} class ExtensionNameExtension implements JsPsychExtension { static info: JsPsychExtensionInfo = { name: "{name}", + version: version, + data: { + /** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data1: { + type: ParameterType.INT, + }, + /** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data2: { + type: ParameterType.STRING, + }, + }, }; constructor(private jsPsych: JsPsych) {} @@ -35,7 +48,8 @@ class ExtensionNameExtension implements JsPsychExtension { on_finish = ({}: OnFinishParameters): { [key: string]: any } => { return { - data_property: "data_value", + data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const. + data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const. }; }; } diff --git a/templates/extension-template-ts/tsconfig.json b/templates/extension-template-ts/tsconfig.json index 3eabd0c2..8a845081 100644 --- a/templates/extension-template-ts/tsconfig.json +++ b/templates/extension-template-ts/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@jspsych/config/tsconfig.contrib.json", "compilerOptions": { - "baseUrl": "." + "baseUrl": ".", + "resolveJsonModule": true }, "include": ["src"] } diff --git a/templates/plugin-template-js/index.js b/templates/plugin-template-js/index.js index e774f51f..7dde75fe 100644 --- a/templates/plugin-template-js/index.js +++ b/templates/plugin-template-js/index.js @@ -3,16 +3,29 @@ var _globalName_ = (function (jspsych) { const info = { name: "{name}", + version: "1.0.0", // When working in a Javascript environment with no build, you will need to manually put set the version information. This is used for metadata purposes and publishing. parameters: { + /** Provide a clear description of the parameter_name that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ parameter_name: { type: jspsych.ParameterType.INT, default: undefined, }, + /** Provide a clear description of the parameter_name2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ parameter_name2: { type: jspsych.ParameterType.IMAGE, default: undefined, }, }, + data: { + /** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data1: { + type: ParameterType.INT, + }, + /** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data2: { + type: ParameterType.STRING, + }, + }, }; /** @@ -30,7 +43,8 @@ var _globalName_ = (function (jspsych) { trial(display_element, trial) { // data saving var trial_data = { - parameter_name: "parameter value", + data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const. + data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const. }; // end trial this.jsPsych.finishTrial(trial_data); diff --git a/templates/plugin-template-ts/src/index.ts b/templates/plugin-template-ts/src/index.ts index 253f62d7..b2396d68 100644 --- a/templates/plugin-template-ts/src/index.ts +++ b/templates/plugin-template-ts/src/index.ts @@ -1,17 +1,32 @@ import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych"; +import { version } from "../package.json"; + const info = { name: "{name}", + version: version, parameters: { + /** Provide a clear description of the parameter_name that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ parameter_name: { type: ParameterType.INT, // BOOL, STRING, INT, FLOAT, FUNCTION, KEY, KEYS, SELECT, HTML_STRING, IMAGE, AUDIO, VIDEO, OBJECT, COMPLEX default: undefined, }, + /** Provide a clear description of the parameter_name2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ parameter_name2: { type: ParameterType.IMAGE, default: undefined, }, }, + data: { + /** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data1: { + type: ParameterType.INT, + }, + /** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */ + data2: { + type: ParameterType.STRING, + }, + }, }; type Info = typeof info; @@ -32,7 +47,8 @@ class PluginNamePlugin implements JsPsychPlugin { trial(display_element: HTMLElement, trial: TrialType) { // data saving var trial_data = { - parameter_name: "parameter value", + data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const. + data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const. }; // end trial diff --git a/templates/plugin-template-ts/tsconfig.json b/templates/plugin-template-ts/tsconfig.json index 3eabd0c2..8a845081 100644 --- a/templates/plugin-template-ts/tsconfig.json +++ b/templates/plugin-template-ts/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@jspsych/config/tsconfig.contrib.json", "compilerOptions": { - "baseUrl": "." + "baseUrl": ".", + "resolveJsonModule": true }, "include": ["src"] }