Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,5 @@
"version": "detect"
}
},
"ignorePatterns": [
"data/",
".github/",
"dist/",
"build/",
"node_modules/",
"*.log"
]
"ignorePatterns": ["data/", ".github/", "dist/", "build/", "node_modules/", "*.log"]
}
40 changes: 22 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,32 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Setup Node ⚙️
uses: actions/setup-node@v1
- name: Checkout repository
uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node 22
uses: actions/setup-node@v6
with:
node-version: "18.x"
- name: Install 🚦
run: yarn
- name: Build 🔨
run: yarn build
node-version: "22.x"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build

test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Setup Node ⚙️
uses: actions/setup-node@v1
- name: Checkout repository
uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node 22
uses: actions/setup-node@v6
with:
node-version: "18.x"
- name: Install 🚦
run: yarn
- name: Test 🧪
run: yarn test
node-version: "22.x"
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# MacOS
.DS_Store

# JetBrains tools
.idea/

# Logs
logs
*.log
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"semi": true,
"trailingComma": "es5",
"singleQuote": false,
"printWidth": 80,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
Expand Down
99 changes: 36 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,60 @@

### Major Versions

> [!NOTE]
> All recent versions include features from prior versions.
> [!IMPORTANT]
> As of [v1.7.13](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.13), Package management has been migrated to use [pnpm](https://pnpm.io/) in light of a recent increase in supply-chain attacks.

* [v1.7.12](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.12) (latest): Includes all social status features, with additional questionnaires and paradigms that can be toggled.
* [v1.7.2](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.2): Includes MRI-compatible features, supporting input from a 4-button controller with UI indicators, and a trigger waiting period. Adds offline support by performing all computations in-browser with `WebR`.
* [v1.7.0](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.0): Initial release, basic 3-Phase experiment timeline, all computations handled by external server requiring persistent internet connectivity.
_All recent versions include features from earlier versions._

- [v1.7.13](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.13) (latest): Includes all social status features, with additional questionnaires and paradigms that can be toggled. Contains small UI fixes to MRI-compatible versions and code quality improvements.
- [v1.7.2](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.2): First version to include MRI-compatible features, supporting input from a 4-button controller with UI indicators, and a trigger waiting period. Adds offline support by performing all computations in-browser with `WebR`. Removes support for external server computations.
- [v1.7.0](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.0): Initial release, basic 3-Phase experiment timeline, all computations handled by external server requiring persistent internet connectivity.

### Development

- `yarn clean`: Remove all client build artefacts and logs.
- `yarn build`: Create a production build of the client.
- `yarn lint`: Run the client source code through ESLint to check for any style violations.
- `yarn start`: Start a Webpack HMR-compatible development server to preview the client locally on [localhost:8080](http://localhost:8080).
- `yarn test`: Run all client tests.
- `pnpm clean`: Remove all client build artefacts and logs.
- `pnpm build`: Create a production build of the client.
- `pnpm lint`: Run the client source code through ESLint to check for any style violations.
- `pnpm start`: Start a Webpack HMR-compatible development server to preview the client locally on [localhost:8080](http://localhost:8080).
- `pnpm test`: Run all client tests.

## Components

### Client

Before building or previewing the client, ensure that the Node.js version 14+ is installed on your system. Download Node.js [here](https://nodejs.org/en/) and install Yarn using this command `npm i -g yarn`.
Before building or previewing the client, ensure that the Node.js version 22+ is installed on your system. Download Node.js [here](https://nodejs.org/en/) and install pnpm using this command `npm i -g pnpm`.

After installing Yarn, run `yarn` in the top-level repository directory to install all dependencies. Refer to [Development](#development) below for other commands to build and preview the client.
After installing pnpm, run `pnpm install` in the top-level repository directory to install all dependencies. Refer to [Development](#development) below for other commands to build and preview the client.

#### Experiment Manipulations

| Parameter | Type | Description | Notes |
| --------------------------------- | ------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **partner** | string | Sets the partner type for testing purposes | `"test"` is a shorter collection of trials, otherwise use `"default"` |
| **requireID** | boolean | Controls whether participant ID is required | |
| **useButtonInput** | boolean | Enables button-based input scheme | Includes additional instructions, enables selection indicators for all screens |
| **useOfflinePackages** | boolean | Enables offline R package usage | Only use for local deployments |
| **enableSocialStatusQuestionnaire** | boolean | Controls display of the social status questionnaire | Shows a social status questionnaire at the start of the experiment |
| **enableEndingQuestionnaires** | boolean | Controls post-experiment questionnaire display | Shows a DASS and social media usage questionnaire at the conclusion of the experiment |
| **useAdultQuestionnaires** | boolean | Enables adult-specific questionnaire content | Requires `enableEndingQuestionnaires` to be `true`, uses the adult questions if `true`, else `false` to show the adolescent set |
| **enableStatusPhaseOne** | boolean | Enables social status display in first phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase One |
| **enableStatusPhaseTwo** | boolean | Enables social status display in second phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase Two |
| **enableStatusPhaseThree** | boolean | Enables social status display in third phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase Three |
| **isPartnerHighStatusPhaseOne** | boolean | Sets partner as high status in first phase | Requires `enableStatusPhaseOne` to be `true` |
| **isPartnerHighStatusPhaseTwo** | boolean | Sets partner as high status in second phase | Requires `enableStatusPhaseTwo` to be `true` |
| **isPartnerHighStatusPhaseThree** | boolean | Sets partner as high status in third phase | Requires `enableStatusPhaseThree` to be `true` |
| **enableCyberball** | boolean | Enables Cyberball exclusion/inclusion task | Includes additional instructions and social status questionnaire prior to experiment starting |
| **cyberballIsInclusive** | boolean | Controls whether Cyberball task is inclusive | Cyberball operates in inclusion mode when `true`, otherwise operating in exclusion mode, changes to probabilities can be made in `configuration.ts` |
| **cyberballIsPartnerHighStatus** | boolean | Sets partner as high status in Cyberball task | Shows social status display above Partner A, partner has high status when `true`, otherwise low status when `false` |
| Parameter | Type | Description | Notes |
| ----------------------------------- | ------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **partner** | string | Sets the partner type for testing purposes | `"test"` is a shorter collection of trials, otherwise use `"default"` |
| **requireID** | boolean | Controls whether participant ID is required | |
| **useButtonInput** | boolean | Enables button-based input scheme | Includes additional instructions, enables selection indicators for all screens |
| **useOfflinePackages** | boolean | Enables offline R package usage | Only use for local deployments |
| **enableSocialStatusQuestionnaire** | boolean | Controls display of the social status questionnaire | Shows a social status questionnaire at the start of the experiment |
| **enableEndingQuestionnaires** | boolean | Controls post-experiment questionnaire display | Shows a DASS and social media usage questionnaire at the conclusion of the experiment |
| **useAdultQuestionnaires** | boolean | Enables adult-specific questionnaire content | Requires `enableEndingQuestionnaires` to be `true`, uses the adult questions if `true`, else `false` to show the adolescent set |
| **enableStatusPhaseOne** | boolean | Enables social status display in first phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase One |
| **enableStatusPhaseTwo** | boolean | Enables social status display in second phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase Two |
| **enableStatusPhaseThree** | boolean | Enables social status display in third phase | Includes additional instructions and social status questionnaire prior to experiment starting, shows status display above partner in Phase Three |
| **isPartnerHighStatusPhaseOne** | boolean | Sets partner as high status in first phase | Requires `enableStatusPhaseOne` to be `true` |
| **isPartnerHighStatusPhaseTwo** | boolean | Sets partner as high status in second phase | Requires `enableStatusPhaseTwo` to be `true` |
| **isPartnerHighStatusPhaseThree** | boolean | Sets partner as high status in third phase | Requires `enableStatusPhaseThree` to be `true` |
| **enableCyberball** | boolean | Enables Cyberball exclusion/inclusion task | Includes additional instructions and social status questionnaire prior to experiment starting |
| **cyberballIsInclusive** | boolean | Controls whether Cyberball task is inclusive | Cyberball operates in inclusion mode when `true`, otherwise operating in exclusion mode, changes to probabilities can be made in `configuration.ts` |
| **cyberballIsPartnerHighStatus** | boolean | Sets partner as high status in Cyberball task | Shows social status display above Partner A, partner has high status when `true`, otherwise low status when `false` |

#### Offline Usage

The task includes a `packages` directory containing all required R packages. To use these packages, set the `useOfflinePackages` manipulation within `Configuration.ts` to `true`. Each package was built and prepared using the [rwasm](https://r-wasm.github.io/rwasm/articles/rwasm.html) tool.

Use the `yarn build` command to build the client with the offline packages, build output is placed in the `dist` directory. To run the task, use the `yarn start` command or run an instance of `http-server` using the `dist` directory.

### Server (DEPRECATED)

> [!CAUTION]
> As of [v1.7.2](https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/releases/tag/v1.7.2), the server component of the Intentions Game has been deprecated, and partner computations are now performed entirely by the client. The documentation below pertains to the archived `server.zip` file contents.

The server uses Python and R to generate partner behavior for a phase of the task. To run the server, the following packages are required:

**Required R packages (including dependencies):**

- `codetools`
- `iterators`
- `jsonlite`
- `foreach`
- `doParallel`
- `cli`
- `generics`
- `glue`
- `lifecycle`
- `magrittr`
- `pillar`
- `R6`
- `rlang`
- `tibble`
- `tidyselect`
- `utf8`
- `fansi`
- `vctrs`
- `pkgconfig`
- `withr`
- `dplyr`
- `logger`
Use the `pnpm build` command to build the client with the offline packages, build output is placed in the `dist` directory. To run the task, use the `pnpm start` command if running from source code. If using a compiled version of the task, start an instance of `http-server` in the directory containing `index.html`.

> [!IMPORTANT]
> For offline operation, `http-server` or an equivalent **must** be used to host and run the experiment locally, otherwise requests to use the `WebR` runtime will be blocked by the browser.

## Additional Features

Expand Down
28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "task_intentions",
"version": "1.7.12",
"version": "1.7.13",
"description": "Intentions Game",
"private": true,
"main": "dist/index.js",
Expand All @@ -23,6 +23,23 @@
"url": "https://github.com/Brain-Development-and-Disorders-Lab/task_intentions/issues"
},
"homepage": "https://github.com/Brain-Development-and-Disorders-Lab/task_intentions#readme",
"packageManager": "pnpm@10.33.0",
"pnpm": {
"overrides": {
"express>path-to-regexp": "~0.1.12",
"axios@>=0.8.1 <0.28.0": ">=0.28.0",
"braces@<3.0.3": ">=3.0.3",
"micromatch@<4.0.8": ">=4.0.8",
"tmp@<=0.2.3": ">=0.2.4",
"axios@<0.30.0": ">=0.30.0",
"axios@<=0.30.2": ">=0.30.3",
"serialize-javascript@<=7.0.2": ">=7.0.3",
"@tootallnate/once@<3.0.1": ">=3.0.1",
"flatted@<3.4.0": ">=3.4.0",
"flatted@<=3.4.1": ">=3.4.2",
"serialize-javascript@<7.0.5": ">=7.0.5"
}
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
Expand All @@ -34,7 +51,8 @@
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/crypto-js": "^4.1.1",
"@types/d3": "^7.1.0",
"@types/d3": "^7.4.3",
"@types/d3-random": "^3.0.3",
"@types/file-saver": "^2.0.7",
"@types/jest": "^29.5.14",
"@types/jest-axe": "^3.5.3",
Expand Down Expand Up @@ -75,9 +93,9 @@
"ts-loader": "^9.2.3",
"typescript": "^5.7.2",
"usehooks-ts": "^2.5.4",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0",
"webpack": "^5.105.4",
"webpack-cli": "^7.0.2",
"webpack-dev-server": "^5.2.3",
"webpack-merge": "^6.0.1",
"webpack-obfuscator": "^3.5.1"
},
Expand Down
Loading
Loading