diff --git a/templates/extension-template-js/index.js b/templates/extension-template-js/index.js index dc206f80..9f74c074 100644 --- a/templates/extension-template-js/index.js +++ b/templates/extension-template-js/index.js @@ -1,3 +1,5 @@ +import { version } from "./package.json"; + var _globalName_ = (function (jspsych) { "use strict"; @@ -26,12 +28,24 @@ var _globalName_ = (function (jspsych) { on_finish(params) { return { - data_property: "data_value", + data_name: 99, // Make sure this type and name matches data_name + data_name2: "hello world!", // Make this this type and name matches data_name2 }; } } ExtensionNameExtension.info = { name: "{name}", + version: version, + data: { + /** This comment will be scraped as metadata for data_name when running the metadata module. */ + data_name: { + type: ParameterType.INT, + }, + /** This comment will be scraped as metadata for data_name2 when running the metadata module. */ + data_name2: { + 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..85ea891f 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: { + /** This comment will be scraped as metadata for data_name when running the metadata module. */ + data_name: { + type: ParameterType.INT, + }, + /** This comment will be scraped as metadata for data_name2 when running the metadata module. */ + data_name2: { + 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", + data_name: 99, // Make sure this type and name matches data_name + data_name2: "hello world!", // Make this this type and name matches data_name2 }; }; } 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..7622e21d 100644 --- a/templates/plugin-template-js/index.js +++ b/templates/plugin-template-js/index.js @@ -1,18 +1,33 @@ +import { version } from "./package.json"; + var _globalName_ = (function (jspsych) { "use strict"; const info = { name: "{name}", + version: version, parameters: { + /** This comment will be scraped as docs for parameter_name when running generating the JsPsych docs. */ parameter_name: { type: jspsych.ParameterType.INT, default: undefined, }, + /** This comment will be scraped as docs for parameter_name2 when running generating the JsPsych docs. */ parameter_name2: { type: jspsych.ParameterType.IMAGE, default: undefined, }, }, + data: { + /** This comment will be scraped as metadata for data_name when running the metadata module. */ + data_name: { + type: jspsych.ParameterType.INT, + }, + /** This comment will be scraped as metadata for data_name2 when running the metadata module. */ + data_name2: { + type: jspsych.ParameterType.STRING, + }, + }, }; /** @@ -30,7 +45,8 @@ var _globalName_ = (function (jspsych) { trial(display_element, trial) { // data saving var trial_data = { - parameter_name: "parameter value", + data_name: 99, // Make sure this type and name matches data_name + data_name2: "hello world!", // Make this this type and name matches data_name2 }; // 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..8c8a6ca0 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: { + /** This comment will be scraped as docs for parameter_name when running generating the JsPsych docs. */ parameter_name: { type: ParameterType.INT, // BOOL, STRING, INT, FLOAT, FUNCTION, KEY, KEYS, SELECT, HTML_STRING, IMAGE, AUDIO, VIDEO, OBJECT, COMPLEX default: undefined, }, + /** This comment will be scraped as docs for parameter_name when running generating the JsPsych docs. */ parameter_name2: { type: ParameterType.IMAGE, default: undefined, }, }, + data: { + /** This comment will be scraped as metadata for data_name when running the metadata module. */ + data_name: { + type: ParameterType.INT, + }, + /** This comment will be scraped as metadata for data_name2 when running the metadata module. */ + data_name2: { + 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", + data_name: 99, // Make sure this type and name matches data_name + data_name2: "hello world!", // Make this this type and name matches data_name2 }; // 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"] }