fix: make the JATOS adapter example runnable, and use jsPsych.multiplayer in examples - #71
Open
htsukamoto5 wants to merge 2 commits into
Open
fix: make the JATOS adapter example runnable, and use jsPsych.multiplayer in examples#71htsukamoto5 wants to merge 2 commits into
htsukamoto5 wants to merge 2 commits into
Conversation
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>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
pluginAPI→jsPsych.multiplayerin seven examples#70 fixed the stale
pluginAPIspelling 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.htmlcalledjsPsych.pluginAPI.connect(...)— live code, not a comment. The plugins tolerate either spelling becauseresolveMultiplayerApi()doesmultiplayer ?? pluginAPI, but a bareconnectreaches 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 onepluginAPI.wait()mention insync's prose.Spelling confirmed against jsPsych#3694's head (
packages/jspsych/src/modules/multiplayer/index.ts) and matchesexamples/group-quiz/index.html:382.2. The JATOS adapter example never loaded
jatos.jsFound 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 whyexamples/group-quiz/index.html:9has the tag. Without it thejatosglobal is undefined and the example throws atjatos.onLoad, beforeconnect()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 afterawait 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 nojsPsych.multiplayerat all, so archives built by those scripts can't run today. That's pre-existing and already self-documented byprintPre3694Caveat()inscripts/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.htmlstill grafts its localStorage shim ontojsPsych.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