mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
Make plugin info static
so it can be accessed before a plugin is instantiated
This commit is contained in:
parent
559f60c83e
commit
56d6fd9d0b
@ -504,13 +504,17 @@ export class JsPsych {
|
||||
this.current_trial = trial;
|
||||
this.current_trial_finished = false;
|
||||
|
||||
// instantiate the plugin for this trial
|
||||
const info = trial.type.info;
|
||||
trial.type = new trial.type(this);
|
||||
|
||||
// process all timeline variables for this trial
|
||||
this.evaluateTimelineVariables(trial);
|
||||
|
||||
// instantiate the plugin for this trial
|
||||
trial.type = {
|
||||
// this is a hack to internally keep the old plugin object structure and prevent touching more
|
||||
// of the core jspsych code
|
||||
...autoBind(new trial.type(this)),
|
||||
info: trial.type.info,
|
||||
};
|
||||
|
||||
// evaluate variables that are functions
|
||||
this.evaluateFunctionParameters(trial);
|
||||
|
||||
|
@ -140,13 +140,10 @@ export interface PluginInfo {
|
||||
}
|
||||
|
||||
export interface JsPsychPlugin<I extends PluginInfo> {
|
||||
info: I;
|
||||
trial(display_element: HTMLElement, trial: TrialType<I>): void;
|
||||
}
|
||||
|
||||
export type TrialType<I extends PluginInfo> = InferredParameters<I["parameters"]> &
|
||||
UniversalPluginParameters;
|
||||
|
||||
export type PluginParameters<P extends JsPsychPlugin<any>> = InferredParameters<
|
||||
P["info"]["parameters"]
|
||||
>;
|
||||
export type PluginParameters<I extends PluginInfo> = InferredParameters<I["parameters"]>;
|
||||
|
@ -166,7 +166,7 @@ describe("nested parameters as functions", () => {
|
||||
};
|
||||
|
||||
class FunctionTestPlugin implements JsPsychPlugin<typeof info> {
|
||||
info = info;
|
||||
static info = info;
|
||||
|
||||
constructor(private jsPsych: JsPsych) {}
|
||||
|
||||
|
@ -67,7 +67,7 @@ type Info = typeof info;
|
||||
*
|
||||
**/
|
||||
class HtmlKeyboardResponsePlugin implements JsPsychPlugin<Info> {
|
||||
info = info;
|
||||
static info = info;
|
||||
|
||||
constructor(private jsPsych: JsPsych) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user