jspsych 7.3.3 → 8.0.0
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/README.md +1 -1
- package/css/jspsych.css +19 -11
- package/dist/index.browser.js +3082 -3399
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +6 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +2464 -3327
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +990 -12
- package/dist/index.js +2463 -3325
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/ExtensionManager.spec.ts +123 -0
- package/src/ExtensionManager.ts +81 -0
- package/src/JsPsych.ts +195 -690
- package/src/ProgressBar.spec.ts +60 -0
- package/src/ProgressBar.ts +60 -0
- package/src/index.scss +29 -8
- package/src/index.ts +4 -9
- package/src/modules/data/DataCollection.ts +1 -1
- package/src/modules/data/DataColumn.ts +12 -1
- package/src/modules/data/index.ts +92 -103
- package/src/modules/extensions.ts +4 -0
- package/src/modules/plugin-api/AudioPlayer.ts +101 -0
- package/src/modules/plugin-api/KeyboardListenerAPI.ts +1 -1
- package/src/modules/plugin-api/MediaAPI.ts +48 -106
- package/src/modules/plugin-api/__mocks__/AudioPlayer.ts +38 -0
- package/src/modules/plugin-api/index.ts +11 -14
- package/src/modules/plugins.ts +26 -27
- package/src/modules/randomization.ts +1 -1
- package/src/timeline/Timeline.spec.ts +921 -0
- package/src/timeline/Timeline.ts +342 -0
- package/src/timeline/TimelineNode.ts +174 -0
- package/src/timeline/Trial.spec.ts +897 -0
- package/src/timeline/Trial.ts +419 -0
- package/src/timeline/index.ts +232 -0
- package/src/timeline/util.spec.ts +124 -0
- package/src/timeline/util.ts +146 -0
- package/dist/JsPsych.d.ts +0 -112
- package/dist/TimelineNode.d.ts +0 -34
- package/dist/migration.d.ts +0 -3
- package/dist/modules/data/DataCollection.d.ts +0 -46
- package/dist/modules/data/DataColumn.d.ts +0 -15
- package/dist/modules/data/index.d.ts +0 -25
- package/dist/modules/data/utils.d.ts +0 -3
- package/dist/modules/extensions.d.ts +0 -22
- package/dist/modules/plugin-api/HardwareAPI.d.ts +0 -15
- package/dist/modules/plugin-api/KeyboardListenerAPI.d.ts +0 -34
- package/dist/modules/plugin-api/MediaAPI.d.ts +0 -32
- package/dist/modules/plugin-api/SimulationAPI.d.ts +0 -44
- package/dist/modules/plugin-api/TimeoutAPI.d.ts +0 -17
- package/dist/modules/plugin-api/index.d.ts +0 -8
- package/dist/modules/plugins.d.ts +0 -136
- package/dist/modules/randomization.d.ts +0 -42
- package/dist/modules/turk.d.ts +0 -40
- package/dist/modules/utils.d.ts +0 -13
- package/src/TimelineNode.ts +0 -544
- package/src/modules/plugin-api/HardwareAPI.ts +0 -32
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ParameterObjectPathCache, parameterPathArrayToString } from "./util";
|
|
2
|
+
|
|
3
|
+
describe("parameterPathArrayToString()", () => {
|
|
4
|
+
it("works with flat paths", () => {
|
|
5
|
+
expect(parameterPathArrayToString(["flat"])).toEqual("flat");
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("works with nested object paths", () => {
|
|
9
|
+
expect(parameterPathArrayToString(["nested", "object", "path"])).toEqual("nested.object.path");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("works with array indices", () => {
|
|
13
|
+
expect(parameterPathArrayToString(["arrayElement", "10"])).toEqual("arrayElement[10]");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("works with nested object paths and array indices", () => {
|
|
17
|
+
expect(parameterPathArrayToString(["nested", "arrayElement", "10", "property"])).toEqual(
|
|
18
|
+
"nested.arrayElement[10].property"
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("ParameterObjectPathCache", () => {
|
|
24
|
+
const rootObject = {
|
|
25
|
+
object: {
|
|
26
|
+
id: 1,
|
|
27
|
+
nestedObject: { id: 2 },
|
|
28
|
+
},
|
|
29
|
+
array: [{ id: 3 }, { id: 4, nestedObject: { id: 5 } }],
|
|
30
|
+
explicitlyUndefined: undefined,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let cache: ParameterObjectPathCache;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
cache = new ParameterObjectPathCache();
|
|
37
|
+
cache.initialize(rootObject);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("lookup()", () => {
|
|
41
|
+
it("works with object properties", () => {
|
|
42
|
+
expect(cache.lookup(["nonExistent"])).toEqual({ doesPathExist: false, value: undefined });
|
|
43
|
+
|
|
44
|
+
expect(cache.lookup(["explicitlyUndefined"])).toEqual({
|
|
45
|
+
doesPathExist: true,
|
|
46
|
+
value: undefined,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(cache.lookup(["object"])).toEqual({
|
|
50
|
+
doesPathExist: true,
|
|
51
|
+
value: rootObject.object,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("works with nested object properties", () => {
|
|
56
|
+
expect(cache.lookup(["object", "nestedObject"])).toEqual({
|
|
57
|
+
doesPathExist: true,
|
|
58
|
+
value: rootObject.object.nestedObject,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(cache.lookup(["nonExistent", "nonExistent"])).toEqual({
|
|
62
|
+
doesPathExist: false,
|
|
63
|
+
value: undefined,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("works with nested array indices", () => {
|
|
68
|
+
expect(cache.lookup(["array", "0"])).toEqual({
|
|
69
|
+
doesPathExist: true,
|
|
70
|
+
value: rootObject.array[0],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(cache.lookup(["array", "1"])).toEqual({
|
|
74
|
+
doesPathExist: true,
|
|
75
|
+
value: rootObject.array[1],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(cache.lookup(["array", "2"])).toEqual({
|
|
79
|
+
doesPathExist: false,
|
|
80
|
+
value: undefined,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(cache.lookup(["array", "1", "nestedObject"])).toEqual({
|
|
84
|
+
doesPathExist: true,
|
|
85
|
+
value: rootObject.array[1].nestedObject,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("set()", () => {
|
|
91
|
+
it("overrides paths of the root object", () => {
|
|
92
|
+
cache.set(["object"], { nested: 1 });
|
|
93
|
+
expect(cache.lookup(["object", "nested"])).toEqual({
|
|
94
|
+
doesPathExist: true,
|
|
95
|
+
value: 1,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
cache.set(["object", "nested"], 2);
|
|
99
|
+
expect(cache.lookup(["object", "nested"])).toEqual({
|
|
100
|
+
doesPathExist: true,
|
|
101
|
+
value: 2,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
cache.set(["array"], [1]);
|
|
105
|
+
expect(cache.lookup(["array", "0"])).toEqual({ doesPathExist: true, value: 1 });
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("reset()", () => {
|
|
110
|
+
it("deletes all set entries", () => {
|
|
111
|
+
cache.set(["object"], { nested: 1 });
|
|
112
|
+
expect(cache.lookup(["object", "nested"])).toEqual({
|
|
113
|
+
doesPathExist: true,
|
|
114
|
+
value: 1,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
cache.reset();
|
|
118
|
+
expect(cache.lookup(["object", "nested"])).toEqual({
|
|
119
|
+
doesPathExist: false,
|
|
120
|
+
value: undefined,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintains a promise and offers a function to resolve it. Whenever the promise is resolved, it is
|
|
3
|
+
* replaced with a new one.
|
|
4
|
+
*/
|
|
5
|
+
export class PromiseWrapper<ResolveType = void> {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.reset();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
private promise: Promise<ResolveType>;
|
|
11
|
+
private resolvePromise: (resolveValue: ResolveType) => void;
|
|
12
|
+
|
|
13
|
+
reset() {
|
|
14
|
+
this.promise = new Promise((resolve) => {
|
|
15
|
+
this.resolvePromise = resolve;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
get() {
|
|
19
|
+
return this.promise;
|
|
20
|
+
}
|
|
21
|
+
resolve(value: ResolveType) {
|
|
22
|
+
this.resolvePromise(value);
|
|
23
|
+
this.reset();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isPromise(value: any): value is Promise<any> {
|
|
28
|
+
return value && typeof value["then"] === "function";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function delay(ms: number) {
|
|
32
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the string representation of a `path` array like accepted by lodash's `get` and `set`
|
|
37
|
+
* functions.
|
|
38
|
+
*/
|
|
39
|
+
export function parameterPathArrayToString([firstPathElement, ...remainingPathElements]: string[]) {
|
|
40
|
+
let pathString = firstPathElement ?? "";
|
|
41
|
+
|
|
42
|
+
for (const pathElement of remainingPathElements) {
|
|
43
|
+
pathString += Number.isNaN(Number.parseInt(pathElement))
|
|
44
|
+
? `.${pathElement}`
|
|
45
|
+
: `[${pathElement}]`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return pathString;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isObjectOrArray(value: any): value is Record<string, any> | any[] {
|
|
52
|
+
return typeof value === "object" && value !== null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type LookupResult = { doesPathExist: boolean; value?: any };
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Initialized with an object, provides a `lookup` method to look up nested object and array paths
|
|
59
|
+
* and a `set` method to override the element that `lookup` uses at a given path. The original
|
|
60
|
+
* object remains unmodified. All looked up values are cached, including those at intermediate
|
|
61
|
+
* paths. This means, `set`ting the element at a path only affects nested path lookups if the paths
|
|
62
|
+
* have not been looked up and cached before.
|
|
63
|
+
*/
|
|
64
|
+
export class ParameterObjectPathCache {
|
|
65
|
+
private static lookupChild(
|
|
66
|
+
objectOrArray: Record<string, any> | any[],
|
|
67
|
+
childName: string
|
|
68
|
+
): LookupResult {
|
|
69
|
+
let doesPathExist: boolean = false;
|
|
70
|
+
let childValue: any;
|
|
71
|
+
|
|
72
|
+
if (Number.isNaN(Number.parseInt(childName))) {
|
|
73
|
+
// `childName` refers to an object property
|
|
74
|
+
if (Object.hasOwn(objectOrArray, childName)) {
|
|
75
|
+
doesPathExist = true;
|
|
76
|
+
childValue = objectOrArray[childName];
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
// `childName` refers to an array index
|
|
80
|
+
if (Number.parseInt(childName) < objectOrArray.length) {
|
|
81
|
+
doesPathExist = true;
|
|
82
|
+
childValue = objectOrArray[childName];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return { doesPathExist, value: childValue };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private cache = new Map<string, any>();
|
|
90
|
+
private rootObject: any;
|
|
91
|
+
|
|
92
|
+
private get(path: string[]) {
|
|
93
|
+
return this.cache.get(path.join("."));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private has(path: string[]) {
|
|
97
|
+
return this.cache.has(path.join("."));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
constructor() {}
|
|
101
|
+
|
|
102
|
+
public initialize(rootObject: any) {
|
|
103
|
+
this.rootObject = rootObject;
|
|
104
|
+
this.cache.set("", rootObject);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public reset() {
|
|
108
|
+
this.cache.clear();
|
|
109
|
+
this.cache.set("", this.rootObject);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public set(path: string[], value: any) {
|
|
113
|
+
this.cache.set(path.join("."), value);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public lookup(path: string[]): LookupResult {
|
|
117
|
+
if (this.has(path)) {
|
|
118
|
+
return { doesPathExist: true, value: this.get(path) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Recursively find the closest ancestor path that has already been cached and start looking up
|
|
122
|
+
// the path from there, caching intermediate elements along the way
|
|
123
|
+
const lookupPath = (path: string[]): LookupResult => {
|
|
124
|
+
const parentPath = path.slice(0, -1);
|
|
125
|
+
const childName = path[path.length - 1];
|
|
126
|
+
if (!this.has(parentPath) && parentPath.length > 0) {
|
|
127
|
+
if (!lookupPath(parentPath).doesPathExist) {
|
|
128
|
+
return { doesPathExist: false };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const parentValue = this.get(parentPath);
|
|
133
|
+
if (!isObjectOrArray(parentValue)) {
|
|
134
|
+
return { doesPathExist: false };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const lookupResult = ParameterObjectPathCache.lookupChild(parentValue, childName);
|
|
138
|
+
if (lookupResult.doesPathExist) {
|
|
139
|
+
this.set(path, lookupResult.value);
|
|
140
|
+
}
|
|
141
|
+
return lookupResult;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return lookupPath(path);
|
|
145
|
+
}
|
|
146
|
+
}
|
package/dist/JsPsych.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { JsPsychData } from "./modules/data";
|
|
2
|
-
import { PluginAPI } from "./modules/plugin-api";
|
|
3
|
-
import * as randomization from "./modules/randomization";
|
|
4
|
-
import * as turk from "./modules/turk";
|
|
5
|
-
import * as utils from "./modules/utils";
|
|
6
|
-
export declare class JsPsych {
|
|
7
|
-
extensions: any;
|
|
8
|
-
turk: typeof turk;
|
|
9
|
-
randomization: typeof randomization;
|
|
10
|
-
utils: typeof utils;
|
|
11
|
-
data: JsPsychData;
|
|
12
|
-
pluginAPI: PluginAPI;
|
|
13
|
-
version(): any;
|
|
14
|
-
/**
|
|
15
|
-
* options
|
|
16
|
-
*/
|
|
17
|
-
private opts;
|
|
18
|
-
/**
|
|
19
|
-
* experiment timeline
|
|
20
|
-
*/
|
|
21
|
-
private timeline;
|
|
22
|
-
private timelineDescription;
|
|
23
|
-
private global_trial_index;
|
|
24
|
-
private current_trial;
|
|
25
|
-
private current_trial_finished;
|
|
26
|
-
private DOM_container;
|
|
27
|
-
private DOM_target;
|
|
28
|
-
/**
|
|
29
|
-
* time that the experiment began
|
|
30
|
-
*/
|
|
31
|
-
private exp_start_time;
|
|
32
|
-
/**
|
|
33
|
-
* is the experiment paused?
|
|
34
|
-
*/
|
|
35
|
-
private paused;
|
|
36
|
-
private waiting;
|
|
37
|
-
/**
|
|
38
|
-
* is the page retrieved directly via file:// protocol (true) or hosted on a server (false)?
|
|
39
|
-
*/
|
|
40
|
-
private file_protocol;
|
|
41
|
-
/**
|
|
42
|
-
* Promise that is resolved when `finishExperiment()` is called
|
|
43
|
-
*/
|
|
44
|
-
private finished;
|
|
45
|
-
private resolveFinishedPromise;
|
|
46
|
-
/**
|
|
47
|
-
* is the experiment running in `simulate()` mode
|
|
48
|
-
*/
|
|
49
|
-
private simulation_mode;
|
|
50
|
-
/**
|
|
51
|
-
* simulation options passed in via `simulate()`
|
|
52
|
-
*/
|
|
53
|
-
private simulation_options;
|
|
54
|
-
webaudio_context: AudioContext;
|
|
55
|
-
internal: {
|
|
56
|
-
/**
|
|
57
|
-
* this flag is used to determine whether we are in a scope where
|
|
58
|
-
* jsPsych.timelineVariable() should be executed immediately or
|
|
59
|
-
* whether it should return a function to access the variable later.
|
|
60
|
-
*
|
|
61
|
-
**/
|
|
62
|
-
call_immediate: boolean;
|
|
63
|
-
};
|
|
64
|
-
constructor(options?: any);
|
|
65
|
-
/**
|
|
66
|
-
* Starts an experiment using the provided timeline and returns a promise that is resolved when
|
|
67
|
-
* the experiment is finished.
|
|
68
|
-
*
|
|
69
|
-
* @param timeline The timeline to be run
|
|
70
|
-
*/
|
|
71
|
-
run(timeline: any[]): Promise<void>;
|
|
72
|
-
simulate(timeline: any[], simulation_mode?: "data-only" | "visual", simulation_options?: {}): Promise<void>;
|
|
73
|
-
getProgress(): {
|
|
74
|
-
total_trials: number;
|
|
75
|
-
current_trial_global: number;
|
|
76
|
-
percent_complete: number;
|
|
77
|
-
};
|
|
78
|
-
getStartTime(): any;
|
|
79
|
-
getTotalTime(): number;
|
|
80
|
-
getDisplayElement(): HTMLElement;
|
|
81
|
-
getDisplayContainerElement(): HTMLElement;
|
|
82
|
-
finishTrial(data?: {}): void;
|
|
83
|
-
endExperiment(end_message?: string, data?: {}): void;
|
|
84
|
-
endCurrentTimeline(): void;
|
|
85
|
-
getCurrentTrial(): any;
|
|
86
|
-
getInitSettings(): any;
|
|
87
|
-
getCurrentTimelineNodeID(): any;
|
|
88
|
-
timelineVariable(varname: string, immediate?: boolean): any;
|
|
89
|
-
getAllTimelineVariables(): any;
|
|
90
|
-
addNodeToEndOfTimeline(new_timeline: any, preload_callback?: any): void;
|
|
91
|
-
pauseExperiment(): void;
|
|
92
|
-
resumeExperiment(): void;
|
|
93
|
-
loadFail(message: any): void;
|
|
94
|
-
getSafeModeStatus(): boolean;
|
|
95
|
-
getTimeline(): any[];
|
|
96
|
-
private prepareDom;
|
|
97
|
-
private loadExtensions;
|
|
98
|
-
private startExperiment;
|
|
99
|
-
private finishExperiment;
|
|
100
|
-
private nextTrial;
|
|
101
|
-
private doTrial;
|
|
102
|
-
private evaluateTimelineVariables;
|
|
103
|
-
private evaluateFunctionParameters;
|
|
104
|
-
private replaceFunctionsWithValues;
|
|
105
|
-
private setDefaultValues;
|
|
106
|
-
private checkExclusions;
|
|
107
|
-
private drawProgressBar;
|
|
108
|
-
private updateProgressBar;
|
|
109
|
-
private progress_bar_amount;
|
|
110
|
-
setProgressBar(proportion_complete: any): void;
|
|
111
|
-
getProgressBarCompleted(): number;
|
|
112
|
-
}
|
package/dist/TimelineNode.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { JsPsych } from "./JsPsych";
|
|
2
|
-
export declare class TimelineNode {
|
|
3
|
-
private jsPsych;
|
|
4
|
-
relative_id: any;
|
|
5
|
-
parent_node: any;
|
|
6
|
-
trial_parameters: any;
|
|
7
|
-
timeline_parameters: any;
|
|
8
|
-
node_trial_data: any;
|
|
9
|
-
progress: any;
|
|
10
|
-
end_message?: string;
|
|
11
|
-
constructor(jsPsych: JsPsych, parameters: any, parent?: any, relativeID?: any);
|
|
12
|
-
trial(): any;
|
|
13
|
-
markCurrentTrialComplete(): void;
|
|
14
|
-
nextRepetiton(): void;
|
|
15
|
-
setTimelineVariablesOrder(): void;
|
|
16
|
-
nextSet(): void;
|
|
17
|
-
advance(): any;
|
|
18
|
-
isComplete(): any;
|
|
19
|
-
getTimelineVariableValue(variable_name: string): any;
|
|
20
|
-
findTimelineVariable(variable_name: any): any;
|
|
21
|
-
timelineVariable(variable_name: string): any;
|
|
22
|
-
allTimelineVariables(): any;
|
|
23
|
-
allTimelineVariablesNames(so_far?: any[]): any;
|
|
24
|
-
length(): number;
|
|
25
|
-
percentComplete(): number;
|
|
26
|
-
reset(): void;
|
|
27
|
-
end(): void;
|
|
28
|
-
endActiveNode(): void;
|
|
29
|
-
ID(): string;
|
|
30
|
-
activeID(): any;
|
|
31
|
-
generatedData(): import("./modules/data/DataCollection").DataCollection;
|
|
32
|
-
trialsOfType(type: any): any;
|
|
33
|
-
insert(parameters: any): void;
|
|
34
|
-
}
|
package/dist/migration.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DataColumn } from "./DataColumn";
|
|
2
|
-
export declare class DataCollection {
|
|
3
|
-
private trials;
|
|
4
|
-
constructor(data?: any[]);
|
|
5
|
-
push(new_data: any): this;
|
|
6
|
-
join(other_data_collection: DataCollection): this;
|
|
7
|
-
top(): DataCollection;
|
|
8
|
-
/**
|
|
9
|
-
* Queries the first n elements in a collection of trials.
|
|
10
|
-
*
|
|
11
|
-
* @param n A positive integer of elements to return. A value of
|
|
12
|
-
* n that is less than 1 will throw an error.
|
|
13
|
-
*
|
|
14
|
-
* @return First n objects of a collection of trials. If fewer than
|
|
15
|
-
* n trials are available, the trials.length elements will
|
|
16
|
-
* be returned.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
first(n?: number): DataCollection;
|
|
20
|
-
/**
|
|
21
|
-
* Queries the last n elements in a collection of trials.
|
|
22
|
-
*
|
|
23
|
-
* @param n A positive integer of elements to return. A value of
|
|
24
|
-
* n that is less than 1 will throw an error.
|
|
25
|
-
*
|
|
26
|
-
* @return Last n objects of a collection of trials. If fewer than
|
|
27
|
-
* n trials are available, the trials.length elements will
|
|
28
|
-
* be returned.
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
last(n?: number): DataCollection;
|
|
32
|
-
values(): any[];
|
|
33
|
-
count(): number;
|
|
34
|
-
readOnly(): DataCollection;
|
|
35
|
-
addToAll(properties: any): this;
|
|
36
|
-
addToLast(properties: any): this;
|
|
37
|
-
filter(filters: any): DataCollection;
|
|
38
|
-
filterCustom(fn: any): DataCollection;
|
|
39
|
-
filterColumns(columns: Array<string>): DataCollection;
|
|
40
|
-
select(column: any): DataColumn;
|
|
41
|
-
ignore(columns: any): DataCollection;
|
|
42
|
-
uniqueNames(): any[];
|
|
43
|
-
csv(): string;
|
|
44
|
-
json(pretty?: boolean): string;
|
|
45
|
-
localSave(format: any, filename: any): void;
|
|
46
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class DataColumn {
|
|
2
|
-
values: any[];
|
|
3
|
-
constructor(values?: any[]);
|
|
4
|
-
sum(): number;
|
|
5
|
-
mean(): number;
|
|
6
|
-
median(): any;
|
|
7
|
-
min(): any;
|
|
8
|
-
max(): any;
|
|
9
|
-
count(): number;
|
|
10
|
-
variance(): number;
|
|
11
|
-
sd(): number;
|
|
12
|
-
frequencies(): {};
|
|
13
|
-
all(eval_fn: any): boolean;
|
|
14
|
-
subset(eval_fn: any): DataColumn;
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { JsPsych } from "../../JsPsych";
|
|
2
|
-
import { DataCollection } from "./DataCollection";
|
|
3
|
-
export declare class JsPsychData {
|
|
4
|
-
private jsPsych;
|
|
5
|
-
private allData;
|
|
6
|
-
private interactionData;
|
|
7
|
-
private dataProperties;
|
|
8
|
-
private query_string;
|
|
9
|
-
constructor(jsPsych: JsPsych);
|
|
10
|
-
reset(): void;
|
|
11
|
-
get(): DataCollection;
|
|
12
|
-
getInteractionData(): DataCollection;
|
|
13
|
-
write(data_object: any): void;
|
|
14
|
-
addProperties(properties: any): void;
|
|
15
|
-
addDataToLastTrial(data: any): void;
|
|
16
|
-
getDataByTimelineNode(node_id: any): DataCollection;
|
|
17
|
-
getLastTrialData(): DataCollection;
|
|
18
|
-
getLastTimelineData(): DataCollection;
|
|
19
|
-
displayData(format?: string): void;
|
|
20
|
-
urlVariables(): any;
|
|
21
|
-
getURLVariable(whichvar: any): any;
|
|
22
|
-
createInteractionListeners(): void;
|
|
23
|
-
_customInsert(data: any): void;
|
|
24
|
-
_fullreset(): void;
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface JsPsychExtensionInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
}
|
|
4
|
-
export interface JsPsychExtension {
|
|
5
|
-
/**
|
|
6
|
-
* Called once at the start of the experiment to initialize the extension
|
|
7
|
-
*/
|
|
8
|
-
initialize(params?: Record<string, any>): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Called at the start of a trial, prior to invoking the plugin's trial method.
|
|
11
|
-
*/
|
|
12
|
-
on_start(params?: Record<string, any>): void;
|
|
13
|
-
/**
|
|
14
|
-
* Called during a trial, after the plugin makes initial changes to the DOM.
|
|
15
|
-
*/
|
|
16
|
-
on_load(params?: Record<string, any>): void;
|
|
17
|
-
/**
|
|
18
|
-
* Called at the end of the trial.
|
|
19
|
-
* @returns Data to append to the trial's data object.
|
|
20
|
-
*/
|
|
21
|
-
on_finish(params?: Record<string, any>): Record<string, any> | Promise<Record<string, any>>;
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class HardwareAPI {
|
|
2
|
-
/**
|
|
3
|
-
* Indicates whether this instance of jspsych has opened a hardware connection through our browser
|
|
4
|
-
* extension
|
|
5
|
-
**/
|
|
6
|
-
hardwareConnected: boolean;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Allows communication with user hardware through our custom Google Chrome extension + native C++ program
|
|
10
|
-
* @param mess The message to be passed to our extension, see its documentation for the expected members of this object.
|
|
11
|
-
* @author Daniel Rivas
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
hardware(mess: any): void;
|
|
15
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export declare type KeyboardListener = (e: KeyboardEvent) => void;
|
|
2
|
-
export declare type ValidResponses = string[] | "ALL_KEYS" | "NO_KEYS";
|
|
3
|
-
export interface GetKeyboardResponseOptions {
|
|
4
|
-
callback_function: any;
|
|
5
|
-
valid_responses?: ValidResponses;
|
|
6
|
-
rt_method?: "performance" | "audio";
|
|
7
|
-
persist?: boolean;
|
|
8
|
-
audio_context?: AudioContext;
|
|
9
|
-
audio_context_start_time?: number;
|
|
10
|
-
allow_held_key?: boolean;
|
|
11
|
-
minimum_valid_rt?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class KeyboardListenerAPI {
|
|
14
|
-
private getRootElement;
|
|
15
|
-
private areResponsesCaseSensitive;
|
|
16
|
-
private minimumValidRt;
|
|
17
|
-
constructor(getRootElement: () => Element | undefined, areResponsesCaseSensitive?: boolean, minimumValidRt?: number);
|
|
18
|
-
private listeners;
|
|
19
|
-
private heldKeys;
|
|
20
|
-
private areRootListenersRegistered;
|
|
21
|
-
/**
|
|
22
|
-
* If not previously done and `this.getRootElement()` returns an element, adds the root key
|
|
23
|
-
* listeners to that element.
|
|
24
|
-
*/
|
|
25
|
-
private registerRootListeners;
|
|
26
|
-
private rootKeydownListener;
|
|
27
|
-
private toLowerCaseIfInsensitive;
|
|
28
|
-
private rootKeyupListener;
|
|
29
|
-
private isResponseValid;
|
|
30
|
-
getKeyboardResponse({ callback_function, valid_responses, rt_method, persist, audio_context, audio_context_start_time, allow_held_key, minimum_valid_rt, }: GetKeyboardResponseOptions): KeyboardListener;
|
|
31
|
-
cancelKeyboardResponse(listener: KeyboardListener): void;
|
|
32
|
-
cancelAllKeyboardResponses(): void;
|
|
33
|
-
compareKeys(key1: string | null, key2: string | null): boolean;
|
|
34
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export declare class MediaAPI {
|
|
2
|
-
private useWebaudio;
|
|
3
|
-
private webaudioContext?;
|
|
4
|
-
constructor(useWebaudio: boolean, webaudioContext?: AudioContext);
|
|
5
|
-
private video_buffers;
|
|
6
|
-
getVideoBuffer(videoID: string): any;
|
|
7
|
-
private context;
|
|
8
|
-
private audio_buffers;
|
|
9
|
-
initAudio(): void;
|
|
10
|
-
audioContext(): any;
|
|
11
|
-
getAudioBuffer(audioID: any): Promise<unknown>;
|
|
12
|
-
private preload_requests;
|
|
13
|
-
private img_cache;
|
|
14
|
-
preloadAudio(files: any, callback_complete?: () => void, callback_load?: (filepath: any) => void, callback_error?: (error_msg: any) => void): void;
|
|
15
|
-
preloadImages(images: any, callback_complete?: () => void, callback_load?: (filepath: any) => void, callback_error?: (error_msg: any) => void): void;
|
|
16
|
-
preloadVideo(videos: any, callback_complete?: () => void, callback_load?: (filepath: any) => void, callback_error?: (error_msg: any) => void): void;
|
|
17
|
-
private preloadMap;
|
|
18
|
-
getAutoPreloadList(timeline_description: any[]): {
|
|
19
|
-
images: string[];
|
|
20
|
-
audio: string[];
|
|
21
|
-
video: string[];
|
|
22
|
-
};
|
|
23
|
-
cancelPreloads(): void;
|
|
24
|
-
private microphone_recorder;
|
|
25
|
-
initializeMicrophoneRecorder(stream: MediaStream): void;
|
|
26
|
-
getMicrophoneRecorder(): MediaRecorder;
|
|
27
|
-
private camera_stream;
|
|
28
|
-
private camera_recorder;
|
|
29
|
-
initializeCameraRecorder(stream: MediaStream, opts?: MediaRecorderOptions): void;
|
|
30
|
-
getCameraStream(): MediaStream;
|
|
31
|
-
getCameraRecorder(): MediaRecorder;
|
|
32
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export declare class SimulationAPI {
|
|
2
|
-
private getDisplayContainerElement;
|
|
3
|
-
private setJsPsychTimeout;
|
|
4
|
-
constructor(getDisplayContainerElement: () => HTMLElement, setJsPsychTimeout: (callback: () => void, delay: number) => number);
|
|
5
|
-
dispatchEvent(event: Event): void;
|
|
6
|
-
/**
|
|
7
|
-
* Dispatches a `keydown` event for the specified key
|
|
8
|
-
* @param key Character code (`.key` property) for the key to press.
|
|
9
|
-
*/
|
|
10
|
-
keyDown(key: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* Dispatches a `keyup` event for the specified key
|
|
13
|
-
* @param key Character code (`.key` property) for the key to press.
|
|
14
|
-
*/
|
|
15
|
-
keyUp(key: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* Dispatches a `keydown` and `keyup` event in sequence to simulate pressing a key.
|
|
18
|
-
* @param key Character code (`.key` property) for the key to press.
|
|
19
|
-
* @param delay Length of time to wait (ms) before executing action
|
|
20
|
-
*/
|
|
21
|
-
pressKey(key: string, delay?: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* Dispatches `mousedown`, `mouseup`, and `click` events on the target element
|
|
24
|
-
* @param target The element to click
|
|
25
|
-
* @param delay Length of time to wait (ms) before executing action
|
|
26
|
-
*/
|
|
27
|
-
clickTarget(target: Element, delay?: number): void;
|
|
28
|
-
/**
|
|
29
|
-
* Sets the value of a target text input
|
|
30
|
-
* @param target A text input element to fill in
|
|
31
|
-
* @param text Text to input
|
|
32
|
-
* @param delay Length of time to wait (ms) before executing action
|
|
33
|
-
*/
|
|
34
|
-
fillTextInput(target: HTMLInputElement, text: string, delay?: number): void;
|
|
35
|
-
/**
|
|
36
|
-
* Picks a valid key from `choices`, taking into account jsPsych-specific
|
|
37
|
-
* identifiers like "NO_KEYS" and "ALL_KEYS".
|
|
38
|
-
* @param choices Which keys are valid.
|
|
39
|
-
* @returns A key selected at random from the valid keys.
|
|
40
|
-
*/
|
|
41
|
-
getValidKey(choices: "NO_KEYS" | "ALL_KEYS" | Array<string> | Array<Array<string>>): any;
|
|
42
|
-
mergeSimulationData(default_data: any, simulation_options: any): any;
|
|
43
|
-
ensureSimulationDataConsistency(trial: any, data: any): void;
|
|
44
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class that provides a wrapper around the global setTimeout and clearTimeout functions.
|
|
3
|
-
*/
|
|
4
|
-
export declare class TimeoutAPI {
|
|
5
|
-
private timeout_handlers;
|
|
6
|
-
/**
|
|
7
|
-
* Calls a function after a specified delay, in milliseconds.
|
|
8
|
-
* @param callback The function to call after the delay.
|
|
9
|
-
* @param delay The number of milliseconds to wait before calling the function.
|
|
10
|
-
* @returns A handle that can be used to clear the timeout with clearTimeout.
|
|
11
|
-
*/
|
|
12
|
-
setTimeout(callback: () => void, delay: number): number;
|
|
13
|
-
/**
|
|
14
|
-
* Clears all timeouts that have been created with setTimeout.
|
|
15
|
-
*/
|
|
16
|
-
clearAllTimeouts(): void;
|
|
17
|
-
}
|