Commit Graph

692 Commits

Author SHA1 Message Date
Josh de Leeuw
c374991d17 update preloading methods to use es6 features 2021-08-25 11:20:53 -04:00
Josh de Leeuw
a77052deb2 replace var where needed 2021-08-25 11:06:11 -04:00
Josh de Leeuw
266f756155 replace var where needed 2021-08-25 11:05:56 -04:00
Josh de Leeuw
b5f06d4144 update tests for es6 2021-08-25 10:56:40 -04:00
Josh de Leeuw
a54ed29e6e update unique() to use es6 Set 2021-08-24 13:45:41 -04:00
Josh de Leeuw
2224784219 replace utility method flatten() with es6 .flat() 2021-08-24 13:44:58 -04:00
Josh de Leeuw
8e58f6e160 cleanup of issues IDed in review 2021-08-23 15:01:21 -04:00
Josh de Leeuw
3500e2b001 fixing const/let, replacing == with === 2021-08-23 14:36:56 -04:00
Josh de Leeuw
5d060f6b96 rename getter methods, update docs 2021-08-23 13:11:32 -04:00
Josh de Leeuw
a3769deb81 for loop update 2021-08-23 12:52:49 -04:00
Josh de Leeuw
254dd6612c update var 2021-08-23 12:51:28 -04:00
Josh de Leeuw
9b2fc7e68b reimplement factorial() method, add tests, replace var with let/const 2021-08-23 11:41:50 -04:00
Josh de Leeuw
019ab49fea replace var with let/const 2021-08-23 10:00:28 -04:00
Josh de Leeuw
4b5a4398c7 update for loops, var keyword 2021-08-23 09:53:08 -04:00
Josh de Leeuw
861f83e185 replace var with let/const; replace some for loops 2021-08-23 09:34:09 -04:00
Josh de Leeuw
c20b2dad49 replace var with let or const 2021-08-23 09:03:30 -04:00
bjoluc
0a8773204e Remove useWebaudio default value in MediaAPI constructor 2021-08-23 11:19:52 +02:00
bjoluc
fee9e19614 Merge branch 'modularization' into preloading 2021-08-23 11:01:24 +02:00
bjoluc
a06b07ddc9 Get rid of reset and createKeyboardEventListeners, instantiate API objects directly in pluginapi tests 2021-08-22 21:59:12 +02:00
bjoluc
39e84a02e2 Remove keycode functionality 2021-08-22 16:25:24 +02:00
bjoluc
cbce6d8919 Replace KeyboardListener objects directly with callback functions 2021-08-22 15:45:55 +02:00
bjoluc
2b82cab264 Remove outdated import in test-extension.ts 2021-08-22 00:33:00 +02:00
bjoluc
c30b6ad19a Rework preloading in MediaAPI
This drops support for the `registerPreload()` function and instead
infers preloading information on the fly in `getAutoPreloadList()`.
2021-08-22 00:11:17 +02:00
bjoluc
bb141c446a Fix class instance access in callback functions
by converting the affected functions to arrow functions to preserve the
outer-scope `this`
2021-08-20 14:17:46 +02:00
Josh de Leeuw
b3b9f5fd5e
Create modular versions of extensions (#2053)
Extensions are now passed to the `JsPsych` constructor via an `extensions` option.
Along the way, the webgazer plugins and plugin-html-button-response have been modularized as well.

Co-authored-by: bjoluc <mail@bjoluc.de>
Co-authored-by: Becky Gilbert <beckyannegilbert@gmail.com>
2021-08-20 11:15:33 +02:00
bjoluc
c340c5ea55 Enhance scripts in package.json files 2021-08-17 20:26:38 +02:00
bjoluc
4fcb2f7e56 Refactor KeyboardListenerAPI 2021-08-17 19:13:30 +02:00
bjoluc
9c519853fe Use enum for parameter types and remove JsPsych.plugins
`const parameterType` is now `enum ParameterType` and can only be
accessed by importing it.
2021-08-17 17:19:25 +02:00
bjoluc
743ad44e84 Replace ALL_KEYS and NO_KEYS with strings
`"ALL_KEYS"` is now used instead of `jsPsych.ALL_KEYS` and `"NO_KEYS"`
instead of `jsPsych.NO_KEYS`
2021-08-17 17:07:23 +02:00
bjoluc
2e17ca6b33 Introduce parameterType.KEYS for multiple keys
It represents an array of keys, or jsPsych.ALL_KEYS and jsPsych.NO_KEYS
2021-08-17 17:07:23 +02:00
bjoluc
64541a451f Implement preload flag for plugin parameters
It defaults to `true` for parameters of type IMAGE, VIDEO, and AUDIO,
and is ignored for any other parameter type.
Example: Using `parameterType.IMAGE` for a parameter `param` in a
plugin named `my-plugin` is equivalent to calling
`jspsych.pluginAPI.registerPreload("my-plugin", "param", "image")`
before `jsPsych.run()`. Setting `preload: false` for the parameter would
disable this invocation.
2021-08-17 16:47:07 +02:00
bjoluc
017b45d87e Make trial_type a string in JsPsychData
I forgot to do this when migrating the core to use plugin objects.
@jansim was first with this in #661, so he gets the credits!

Closes #2076
Co-authored-by: Jan Simson <jan.simson@three-2-one.com>
2021-08-12 18:06:22 +02:00
bjoluc
56d6fd9d0b Make plugin info static
so it can be accessed before a plugin is instantiated
2021-08-12 17:25:26 +02:00
bjoluc
c119650471 Move experiment execution into jsPsych.run()
The `run()` method takes a timeline and returns a promise that is
resolved when the experiment finishes.
Hence, jsPsych can now be initialized without starting an experiment.
This re-enables usage of `jsPsych.timelineVariable()` in timeline
definitions and repairs exclusion checks and extension loading.
2021-07-19 17:10:37 +02:00
bjoluc
82fa8e3f29 Add explicit include option to TS configs
So VS Code ignores the `dist` folders
2021-07-13 09:54:29 +02:00
bjoluc
8cfbba526a Use classes to avoid global state
Instead of a global `jsPsych` object, there is a `JsPsych` class now
which can be instantiated with the parameters that were previously
accepted by `jsPsych.init`. Upon instantiation, the `JsPsych` class also
instantiates classes for stateful modules (`jsPsych.data` and
`jsPsych.pluginAPI`) and passes relevant `JsPsych` instance information
to them. Plugins are expected to be classes now that are instantiated
for each trial and receive the `JsPsych` instance as their only
constructor argument.
2021-07-12 18:15:37 +02:00
bjoluc
9afacdfd90 Fix paths in TS configs 2021-07-08 23:32:30 +02:00
bjoluc
91e7b1e3ff Migrate to TypeScript 2021-07-06 17:55:42 +02:00
bjoluc
584a8879ef Highlight plugin projects in jest test runs 2021-07-01 13:07:28 +02:00
bjoluc
d12052c774 Decompose jspsych core into ES6 modules 2021-07-01 12:46:41 +02:00
bjoluc
83f449c635 Utilize jest's monorepo support 2021-06-30 19:29:38 +02:00
bjoluc
744e67b0a5 Setup monorepo and switch to ES6 modules
* Convert jsPsych and plugins to ES6 modules
* Create packages for each plugin, the core library, and config files
* Setup rollup, jest, and babel configurations
* Update jsPsych to load plugin objects directly from the `type` field
* Update tests to use the ES6 modules
2021-06-23 22:39:38 +02:00