jspsych 7.1.1 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/jspsych.css +322 -12
- package/dist/index.browser.js +147 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +147 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/data/DataCollection.d.ts +1 -0
- package/dist/modules/plugins.d.ts +7 -0
- package/dist/modules/randomization.d.ts +7 -0
- package/package.json +20 -7
- package/src/JsPsych.ts +3 -1
- package/src/index.scss +209 -0
- package/src/modules/data/DataCollection.ts +8 -0
- package/src/modules/plugins.ts +7 -0
- package/src/modules/randomization.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
27
|
+
|
|
26
28
|
// Gets all non-builtin properties up the prototype chain
|
|
27
29
|
const getAllProperties = object => {
|
|
28
30
|
const properties = new Set();
|
|
@@ -65,7 +67,7 @@ var autoBind = (self, {include, exclude} = {}) => {
|
|
|
65
67
|
return self;
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
var version = "7.
|
|
70
|
+
var version = "7.2.1";
|
|
69
71
|
|
|
70
72
|
class MigrationError extends Error {
|
|
71
73
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -405,6 +407,9 @@ class DataCollection {
|
|
|
405
407
|
filterCustom(fn) {
|
|
406
408
|
return new DataCollection(this.trials.filter(fn));
|
|
407
409
|
}
|
|
410
|
+
filterColumns(columns) {
|
|
411
|
+
return new DataCollection(this.trials.map((trial) => Object.fromEntries(columns.filter((key) => key in trial).map((key) => [key, trial[key]]))));
|
|
412
|
+
}
|
|
408
413
|
select(column) {
|
|
409
414
|
const values = [];
|
|
410
415
|
for (const trial of this.trials) {
|
|
@@ -806,6 +811,13 @@ const universalPluginParameters = {
|
|
|
806
811
|
pretty_name: "Custom CSS classes",
|
|
807
812
|
default: null,
|
|
808
813
|
},
|
|
814
|
+
/**
|
|
815
|
+
* Options to control simulation mode for the trial.
|
|
816
|
+
*/
|
|
817
|
+
simulation_options: {
|
|
818
|
+
type: ParameterType.COMPLEX,
|
|
819
|
+
default: null,
|
|
820
|
+
},
|
|
809
821
|
};
|
|
810
822
|
|
|
811
823
|
const preloadParameterTypes = [
|
|
@@ -1612,6 +1624,135 @@ var randomWords$1 = words;
|
|
|
1612
1624
|
// Export the word list as it is often useful
|
|
1613
1625
|
words.wordList = wordList;
|
|
1614
1626
|
|
|
1627
|
+
var alea = {exports: {}};
|
|
1628
|
+
|
|
1629
|
+
(function (module) {
|
|
1630
|
+
// A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
|
|
1631
|
+
// http://baagoe.com/en/RandomMusings/javascript/
|
|
1632
|
+
// https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
|
|
1633
|
+
// Original work is under MIT license -
|
|
1634
|
+
|
|
1635
|
+
// Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
|
|
1636
|
+
//
|
|
1637
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1638
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
1639
|
+
// in the Software without restriction, including without limitation the rights
|
|
1640
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1641
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
1642
|
+
// furnished to do so, subject to the following conditions:
|
|
1643
|
+
//
|
|
1644
|
+
// The above copyright notice and this permission notice shall be included in
|
|
1645
|
+
// all copies or substantial portions of the Software.
|
|
1646
|
+
//
|
|
1647
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1648
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1649
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1650
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1651
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1652
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1653
|
+
// THE SOFTWARE.
|
|
1654
|
+
|
|
1655
|
+
|
|
1656
|
+
|
|
1657
|
+
(function(global, module, define) {
|
|
1658
|
+
|
|
1659
|
+
function Alea(seed) {
|
|
1660
|
+
var me = this, mash = Mash();
|
|
1661
|
+
|
|
1662
|
+
me.next = function() {
|
|
1663
|
+
var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
|
|
1664
|
+
me.s0 = me.s1;
|
|
1665
|
+
me.s1 = me.s2;
|
|
1666
|
+
return me.s2 = t - (me.c = t | 0);
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
// Apply the seeding algorithm from Baagoe.
|
|
1670
|
+
me.c = 1;
|
|
1671
|
+
me.s0 = mash(' ');
|
|
1672
|
+
me.s1 = mash(' ');
|
|
1673
|
+
me.s2 = mash(' ');
|
|
1674
|
+
me.s0 -= mash(seed);
|
|
1675
|
+
if (me.s0 < 0) { me.s0 += 1; }
|
|
1676
|
+
me.s1 -= mash(seed);
|
|
1677
|
+
if (me.s1 < 0) { me.s1 += 1; }
|
|
1678
|
+
me.s2 -= mash(seed);
|
|
1679
|
+
if (me.s2 < 0) { me.s2 += 1; }
|
|
1680
|
+
mash = null;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
function copy(f, t) {
|
|
1684
|
+
t.c = f.c;
|
|
1685
|
+
t.s0 = f.s0;
|
|
1686
|
+
t.s1 = f.s1;
|
|
1687
|
+
t.s2 = f.s2;
|
|
1688
|
+
return t;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
function impl(seed, opts) {
|
|
1692
|
+
var xg = new Alea(seed),
|
|
1693
|
+
state = opts && opts.state,
|
|
1694
|
+
prng = xg.next;
|
|
1695
|
+
prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
|
|
1696
|
+
prng.double = function() {
|
|
1697
|
+
return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
|
|
1698
|
+
};
|
|
1699
|
+
prng.quick = prng;
|
|
1700
|
+
if (state) {
|
|
1701
|
+
if (typeof(state) == 'object') copy(state, xg);
|
|
1702
|
+
prng.state = function() { return copy(xg, {}); };
|
|
1703
|
+
}
|
|
1704
|
+
return prng;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
function Mash() {
|
|
1708
|
+
var n = 0xefc8249d;
|
|
1709
|
+
|
|
1710
|
+
var mash = function(data) {
|
|
1711
|
+
data = String(data);
|
|
1712
|
+
for (var i = 0; i < data.length; i++) {
|
|
1713
|
+
n += data.charCodeAt(i);
|
|
1714
|
+
var h = 0.02519603282416938 * n;
|
|
1715
|
+
n = h >>> 0;
|
|
1716
|
+
h -= n;
|
|
1717
|
+
h *= n;
|
|
1718
|
+
n = h >>> 0;
|
|
1719
|
+
h -= n;
|
|
1720
|
+
n += h * 0x100000000; // 2^32
|
|
1721
|
+
}
|
|
1722
|
+
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
1723
|
+
};
|
|
1724
|
+
|
|
1725
|
+
return mash;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
if (module && module.exports) {
|
|
1730
|
+
module.exports = impl;
|
|
1731
|
+
} else if (define && define.amd) {
|
|
1732
|
+
define(function() { return impl; });
|
|
1733
|
+
} else {
|
|
1734
|
+
this.alea = impl;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
})(
|
|
1738
|
+
commonjsGlobal,
|
|
1739
|
+
module, // present in node.js
|
|
1740
|
+
(typeof undefined) == 'function' // present with an AMD loader
|
|
1741
|
+
);
|
|
1742
|
+
}(alea));
|
|
1743
|
+
|
|
1744
|
+
var seedrandom = alea.exports;
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* Uses the `seedrandom` package to replace Math.random() with a seedable PRNG.
|
|
1748
|
+
*
|
|
1749
|
+
* @param seed An optional seed. If none is given, a random seed will be generated.
|
|
1750
|
+
* @returns The seed value.
|
|
1751
|
+
*/
|
|
1752
|
+
function setSeed(seed = Math.random().toString()) {
|
|
1753
|
+
Math.random = seedrandom(seed);
|
|
1754
|
+
return seed;
|
|
1755
|
+
}
|
|
1615
1756
|
function repeat(array, repetitions, unpack = false) {
|
|
1616
1757
|
const arr_isArray = Array.isArray(array);
|
|
1617
1758
|
const rep_isArray = Array.isArray(repetitions);
|
|
@@ -1894,6 +2035,7 @@ function unpackArray(array) {
|
|
|
1894
2035
|
|
|
1895
2036
|
var randomization = /*#__PURE__*/Object.freeze({
|
|
1896
2037
|
__proto__: null,
|
|
2038
|
+
setSeed: setSeed,
|
|
1897
2039
|
repeat: repeat,
|
|
1898
2040
|
shuffle: shuffle,
|
|
1899
2041
|
shuffleNoRepeats: shuffleNoRepeats,
|
|
@@ -2618,7 +2760,10 @@ class JsPsych {
|
|
|
2618
2760
|
// done with callbacks
|
|
2619
2761
|
this.internal.call_immediate = false;
|
|
2620
2762
|
// wait for iti
|
|
2621
|
-
if (
|
|
2763
|
+
if (this.simulation_mode === "data-only") {
|
|
2764
|
+
this.nextTrial();
|
|
2765
|
+
}
|
|
2766
|
+
else if (typeof current_trial.post_trial_gap === null ||
|
|
2622
2767
|
typeof current_trial.post_trial_gap === "undefined") {
|
|
2623
2768
|
if (this.opts.default_iti > 0) {
|
|
2624
2769
|
setTimeout(this.nextTrial, this.opts.default_iti);
|