Skip to content

fix: make the JATOS adapter example runnable, and use jsPsych.multiplayer in examples - #71

Open
htsukamoto5 wants to merge 2 commits into
mainfrom
chore/fix-stale-pluginapi-examples
Open

fix: make the JATOS adapter example runnable, and use jsPsych.multiplayer in examples#71
htsukamoto5 wants to merge 2 commits into
mainfrom
chore/fix-stale-pluginapi-examples

Conversation

@htsukamoto5

@htsukamoto5 htsukamoto5 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Follow-up to #70, found while verifying that PR's "no other drift" claim. Two commits, both about examples that could not run as shipped.

1. pluginAPIjsPsych.multiplayer in seven examples

#70 fixed the stale pluginAPI spelling in the vendored contract headers and the local adapter's changelog; the same spelling survived in seven examples it didn't touch.

The one that mattered: packages/adapter-multiplayer-jatos/examples/index.html called jsPsych.pluginAPI.connect(...) — live code, not a comment. The plugins tolerate either spelling because resolveMultiplayerApi() does multiplayer ?? pluginAPI, but a bare connect reaches core directly with no such fallback, and jsPsych#3694 removed the old location rather than aliasing it. The other six are the commented "connect a multiplayer adapter before running" recipe that live call is copied from (sync, choice, match, ready, role, scoreboard), plus one pluginAPI.wait() mention in sync's prose.

Spelling confirmed against jsPsych#3694's head (packages/jspsych/src/modules/multiplayer/index.ts) and matches examples/group-quiz/index.html:382.

2. The JATOS adapter example never loaded jatos.js

Found while packaging that example as a study to test commit 1. It had no <script src="jatos.js">, and a comment claiming "jatos.js is injected by JATOS at runtime." It isn't — JATOS serves it from the study root but the page must request it, which is why examples/group-quiz/index.html:9 has the tag. Without it the jatos global is undefined and the example throws at jatos.onLoad, before connect() is ever reached. Tag added, comment corrected.

Verification

Ran in a real JATOS instance against a jsPsych#3694 preview build (jsDelivr @151ab52, the pin the root demos use), packaged as a group study. The study reaches "Connected to the JATOS group session. Press any key." with a clean console, then ends on a keypress — correct, since the timeline is a single trial. That message only renders after await connect(...) resolves, so it is direct evidence for both commits.

Note this needed a preview core: npm run build:jatos:* bundles released jspsych 8.2.3, which has no jsPsych.multiplayer at all, so archives built by those scripts can't run today. That's pre-existing and already self-documented by printPre3694Caveat() in scripts/lib/build-jatos-study.js; it resolves when #3694 releases. Flagging it because it also means the committed group-quiz archive is non-functional today.

Deliberately not changed

plugin-multiplayer-ready/examples/demo.html still grafts its localStorage shim onto jsPsych.pluginAPI. It works via the fallback branch and is that branch's last consumer, so it should move in the same change that drops the fallback once #3694 is released — not split across two PRs.

Examples only. No source, no behavior change. Prettier baseline unchanged (these files had pre-existing warnings, untouched here).

🤖 Generated with Claude Code

htsukamoto5 and others added 2 commits July 29, 2026 12:24
jsPsych#3694 moved the multiplayer API off `jsPsych.pluginAPI` onto its
own `jsPsych.multiplayer` module and removed the old location rather
than aliasing it, but seven examples still showed the old spelling.

The JATOS adapter example was the one that mattered: its
`jsPsych.pluginAPI.connect(...)` is live code, not a comment, and a bare
connect call has no fallback (the plugins' resolveMultiplayerApi() does
`multiplayer ?? pluginAPI`, but core's connect is reached directly), so
it throws against a current preview build. The other six are the
commented "connect an adapter" recipe that example is copied from.

Matches examples/group-quiz/index.html, which already uses
jsPsych.multiplayer.connect(). Leaves plugin-multiplayer-ready's
demo.html on pluginAPI: it works via that fallback and should move in
the same change that drops the fallback, once #3694 is released.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The example never loaded jatos.js, and its comment claimed JATOS injects
it at runtime. It doesn't — JATOS serves jatos.js from the study root,
but the study page must request it. Without the tag the `jatos` global
is undefined and the example throws at jatos.onLoad, before connect() is
ever reached, so it could not run as shipped.

examples/group-quiz/index.html already has the tag; this brings the
adapter example in line with it and corrects the comment.

Verified in JATOS against a jsPsych#3694 preview build: the study
reaches "Connected to the JATOS group session. Press any key." with a
clean console, which only renders after `await connect(...)` resolves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@htsukamoto5 htsukamoto5 changed the title docs: use jsPsych.multiplayer in examples instead of pluginAPI fix: make the JATOS adapter example runnable, and use jsPsych.multiplayer in examples Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant