-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2858 from jspsych/core-rewrite
Core rewrite
- Loading branch information
Showing
321 changed files
with
11,538 additions
and
20,410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@jspsych/plugin-html-button-response": major | ||
"jspsych": patch | ||
--- | ||
|
||
Button plugins now support either `display: grid` or `display: flex` on the container element that hold the buttons. If the layout is `grid`, the number of rows and/or columns can be specified. The `margin_horizontal` and `margin_vertical` parameters have been removed from the button plugins. If you need control over the button CSS, you can add inline style to the button element using the `button_html` parameter. | ||
|
||
jspsych.css has new layout classes to support this feature. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
"@jspsych/plugin-audio-button-response": major | ||
"@jspsych/plugin-canvas-button-response": major | ||
"@jspsych/plugin-html-button-response": major | ||
"@jspsych/plugin-image-button-response": major | ||
"@jspsych/plugin-video-button-response": major | ||
--- | ||
|
||
- Make `button_html` a function parameter which, given a choice's text and its index, returns the HTML string of the choice's button. If you were previously passing a string to `button_html`, like `<button>%choice%</button>`, you can now pass the function | ||
```js | ||
function (choice) { | ||
return '<button class="jspsych-btn">' + choice + "</button>"; | ||
} | ||
``` | ||
Similarly, if you were using the array syntax, like | ||
```js | ||
['<button class="a">%choice%</button>', '<button class="b">%choice%</button>', '<button class="a">%choice%</button>'] | ||
``` | ||
an easy way to migrate your trial definition is to pass a function which accesses your array and replaces the `%choice%` placeholder: | ||
```js | ||
function (choice, choice_index) { | ||
return ['<button class="a">%choice%</button>', '<button class="b">%choice%</button>', '<button class="a">%choice%</button>'][choice_index].replace("%choice%", choice); | ||
} | ||
``` | ||
From there on, you can further simplify your function. For instance, if the intention of the above example is to have alternating button classes, the `button_html` function might be rewritten as | ||
```js | ||
function (choice, choice_index) { | ||
return '<button class="' + (choice_index % 2 === 0 ? "a" : "b") + '">' + choice + "</button>"; | ||
} | ||
``` | ||
- Simplify the button DOM structure and styling: Buttons are no longer wrapped in individual container `div`s for spacing and `data-choice` attributes. Instead, each button is assigned its `data-choice` attribute and all buttons are direct children of the button group container `div`. The container `div`, in turn, utilizes a flexbox layout to position the buttons. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@jspsych/config": major | ||
--- | ||
|
||
Activate TypeScript's `isolatedModules` flag in the root `tsconfig.json` file. If you are facing any TypeScript errors due to `isolatedModules`, please update your code according to the error messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
"jspsych": major | ||
--- | ||
|
||
Rewrite jsPsych's core logic. The following breaking changes have been made: | ||
|
||
**Timeline Events** | ||
|
||
- `conditional_function` is no longer executed on every iteration of a looping timeline, but only once before running the first trial of the timeline. If you rely on the old behavior, move your `conditional_function` into a nested timeline instead. | ||
- `on_timeline_start` and `on_timeline_finish` are no longer invoked in every repetition of a timeline, but only at the beginning or at the end of the timeline, respectively. If you rely on the old behavior, move the `on_timeline_start` and `on_timeline_finish` callbacks into a nested timeline. | ||
|
||
**Timeline Variables** | ||
|
||
- The functionality of `jsPsych.timelineVariable()` has been explicitly split into two functions, `jsPsych.timelineVariable()` and `jsPsych.evaluateTimelineVariable()`. Use `jsPsych.timelineVariable()` to create a timeline variable placeholder and `jsPsych.evaluateTimelineVariable()` to retrieve a given timeline variable's current value. | ||
- `jsPsych.evaluateTimelineVariable()` now throws an error if a variable is not found. | ||
- `jsPsych.getAllTimelineVariables()` has been replaced by a trial-level `save_timeline_variables` parameter that can be used to include all or some timeline variables in a trial's result data. | ||
|
||
**Parameter Handling** | ||
|
||
- JsPsych will now throw an error when a non-array value is used for a trial parameter marked as `array: true` in the plugin's info object. | ||
- Parameter functions and timeline variables are no longer automatically evaluated recursively throughout the whole trial object, but only for the parameters that a plugin specifies in its `info` object. Parameter functions and timeline variables in nested objects are only evaluated if the nested object's parameters are explicitly specified using the `nested` property in the parameter description. | ||
|
||
**Progress Bar** | ||
|
||
- `jsPsych.setProgressBar(x)` has been replaced by `jsPsych.progressBar.progress = x` | ||
- `jsPsych.getProgressBarCompleted()` has been replaced by `jsPsych.progressBar.progress` | ||
- The automatic progress bar updates after every trial now, including trials in nested timelines. | ||
|
||
**Data Handling** | ||
|
||
- Timeline nodes no longer have IDs. As a consequence, the `internal_node_id` trial result property and `jsPsych.data.getDataByTimelineNode()` have been removed. | ||
- Unlike previously, the `save_trial_parameters` parameter can only be used to remove parameters that are specified in the plugin's info object. Other result properties will be left untouched. | ||
|
||
**Miscellaneous Changes** | ||
|
||
- `jsPsych.endExperiment()` and `jsPsych.endCurrentTimeline()` have been renamed to `jsPsych.abortExperiment()` and `jsPsych.abortCurrentTimeline()`, respectively. | ||
- JsPsych now internally relies on the JavaScript event loop. This means automated tests have to `await` utility functions like `pressKey()` to process the event loop. | ||
- The `jspsych` package no longer exports `universalPluginParameters` and the `UniversalPluginParameters` type. | ||
- Interaction listeners are now removed when the experiment ends. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@jspsych/config": major | ||
--- | ||
|
||
Migrate the build chain from TypeScript, Babel, and Terser to [esbuild](https://esbuild.github.io/). Babel and Terser are no longer included as dependencies and the Babel configuration at `@jspsych/config/babel` has been removed. The minified browser builds are only transpiled down to [ES2015](https://caniuse.com/es6) now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@jspsych/config": major | ||
--- | ||
|
||
Upgrade Jest to v29 and replace ts-jest with the more performant Sucrase Jest plugin. As a consequence, Jest does no longer type-check code. Please check Jest's [upgrade guide](https://jestjs.io/docs/upgrading-to-jest29) for instructions on updating your tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@jspsych/config": major | ||
--- | ||
|
||
Require at least Node.js v18 and npm v8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@jspsych/test-utils": minor | ||
--- | ||
|
||
Call `flushPromises()` in event-dispatching utility functions to simplify tests involving jsPsych 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
cff-version: "1.2.0" | ||
authors: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
- family-names: Gilbert | ||
given-names: Rebecca A. | ||
orcid: "https://orcid.org/0000-0003-4574-7792" | ||
- family-names: Luchterhandt | ||
given-names: Björn | ||
orcid: "https://orcid.org/0000-0002-9225-2787" | ||
contact: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
doi: 10.5281/zenodo.7702307 | ||
message: If you use this software, please cite our article in the | ||
Journal of Open Source Software. | ||
preferred-citation: | ||
authors: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
- family-names: Gilbert | ||
given-names: Rebecca A. | ||
orcid: "https://orcid.org/0000-0003-4574-7792" | ||
- family-names: Luchterhandt | ||
given-names: Björn | ||
orcid: "https://orcid.org/0000-0002-9225-2787" | ||
date-published: 2023-05-11 | ||
doi: 10.21105/joss.05351 | ||
issn: 2475-9066 | ||
issue: 85 | ||
journal: Journal of Open Source Software | ||
publisher: | ||
name: Open Journals | ||
start: 5351 | ||
title: "jsPsych: Enabling an Open-Source Collaborative Ecosystem of | ||
Behavioral Experiments" | ||
type: article | ||
url: "https://joss.theoj.org/papers/10.21105/joss.05351" | ||
volume: 8 | ||
title: "jsPsych: Enabling an Open-Source Collaborative Ecosystem of | ||
Behavioral Experiments" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.