mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-12 08:38:10 +00:00
Merge pull request #355 from thewhodidthis/nf#335--deps
Declare dependencies in package.json, use imports and esbuild for bundling JS/CSS
This commit is contained in:
commit
994bc98a96
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
dist
|
||||
node_modules
|
||||
out
|
||||
node_modules
|
||||
|
11737
package-lock.json
generated
11737
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
83
package.json
83
package.json
@ -8,69 +8,42 @@
|
||||
"name": "Alain Pitiot"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "src/index.js",
|
||||
"exports": {
|
||||
".": "./src/index.js",
|
||||
"./css": "./src/index.css",
|
||||
"./package": "./package.json"
|
||||
},
|
||||
"main": "./src/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:js && npm run build:css && npm run build:docs",
|
||||
"build:css": "npx cross-var postcss -o dist/psychojs-$npm_package_version.css src/index.css",
|
||||
"build:css": "node ./scripts/build.css.cjs",
|
||||
"build:docs": "jsdoc src -r -d docs",
|
||||
"build:js": "rollup -c",
|
||||
"build:js": "node ./scripts/build.js.cjs",
|
||||
"lint": "npm run lint:js && npm run lint:css",
|
||||
"lint:css": "stylelint src/**/*.css",
|
||||
"lint:js": "eslint rollup.config.js src/**/*.js",
|
||||
"lint:css": "csslint src",
|
||||
"lint:js": "eslint src",
|
||||
"lint:scripts": "eslint scripts --ext .cjs",
|
||||
"start": "npm run build"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"modules": false,
|
||||
"targets": {
|
||||
"ie": 11
|
||||
},
|
||||
"spec": true,
|
||||
"forceAllTransforms": true,
|
||||
"debug": true
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"browserslist": [
|
||||
"last 2 versions"
|
||||
],
|
||||
"stylelint": {
|
||||
"extends": "stylelint-config-standard",
|
||||
"rules": {
|
||||
"no-descending-specificity": [
|
||||
true,
|
||||
{
|
||||
"severity": "warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
"dependencies": {
|
||||
"howler": "^2.2.1",
|
||||
"log4javascript": "github:Ritzlgrmft/log4javascript",
|
||||
"moment": "^2.29.1",
|
||||
"pako": "^1.0.10",
|
||||
"pixi.js-legacy": "^6.0.4",
|
||||
"preload-js": "^0.6.3",
|
||||
"seedrandom": "^3.0.5",
|
||||
"tone": "^14.7.77",
|
||||
"xlsx": "^0.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/preset-env": "^7.12.1",
|
||||
"@rollup/plugin-babel": "^5.2.1",
|
||||
"cross-var": "^1.1.0",
|
||||
"cssnano": "^4.1.10",
|
||||
"eslint": "^7.24.0",
|
||||
"jsdoc": "^3.6.6",
|
||||
"postcss": "^8.1.3",
|
||||
"postcss-cli": "^8.1.0",
|
||||
"postcss-preset-env": "^6.7.0",
|
||||
"rollup": "^2.32.1",
|
||||
"stylelint": "^13.7.2",
|
||||
"stylelint-config-standard": "^20.0.0",
|
||||
"terser": "^5.3.8"
|
||||
"csslint": "^1.0.5",
|
||||
"esbuild": "^0.12.1",
|
||||
"eslint": "^7.26.0",
|
||||
"jsdoc": "^3.6.7"
|
||||
},
|
||||
"postcss": {
|
||||
"plugins": {
|
||||
"postcss-preset-env": {},
|
||||
"cssnano": {
|
||||
"autoprefixer": false
|
||||
}
|
||||
}
|
||||
"engines": {
|
||||
"node": ">=14.15.0",
|
||||
"npm": ">=6.14.8"
|
||||
}
|
||||
}
|
||||
|
212
rollup.config.js
212
rollup.config.js
@ -1,212 +0,0 @@
|
||||
// ES native imports courtesy of using type module in 'package.json'
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { minify } from 'terser';
|
||||
import babel from '@rollup/plugin-babel';
|
||||
import pkg from './package.json';
|
||||
|
||||
// Manually set default version here for easier
|
||||
// diffing when comparing to original build script output
|
||||
const { VERSION: version = pkg.version } = process.env;
|
||||
|
||||
// Enabled in the original, even though
|
||||
// source maps missing for sample provided
|
||||
const sourcemap = false;
|
||||
|
||||
// Might be 'build' or similar
|
||||
const destination = './dist';
|
||||
|
||||
// Could be 'src' or 'lib'
|
||||
const source = './src';
|
||||
|
||||
// Start fresh
|
||||
try {
|
||||
if (fs.existsSync(destination)) {
|
||||
// Clear out JS files before rebuilding
|
||||
const contents = fs.readdirSync(destination).filter(item => item.endsWith('js'));
|
||||
|
||||
for (const item of contents) {
|
||||
const target = path.join(destination, item);
|
||||
const stat = fs.statSync(target);
|
||||
|
||||
// Delete
|
||||
fs.unlinkSync(target);
|
||||
}
|
||||
} else {
|
||||
// Create 'dist' if missing
|
||||
fs.mkdirSync(destination);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
// For sorting legacy/IE11 bundle components
|
||||
const orderOfAppearance = [ 'util', 'data', 'core', 'visual', 'sound' ];
|
||||
const last = [ ...orderOfAppearance ].pop();
|
||||
const footer = `
|
||||
// Add a few top level variables for convenience, this makes it
|
||||
// possible to eg. use "return Scheduler.Event.NEXT;" instead of "util.Scheduler.Event.NEXT;"
|
||||
PsychoJS = core.PsychoJS;
|
||||
TrialHandler = data.TrialHandler;
|
||||
Scheduler = util.Scheduler;`;
|
||||
|
||||
const plugins = [
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
exclude: 'node_modules/**',
|
||||
include: `${destination}/*.iife.js`
|
||||
}),
|
||||
minifier({
|
||||
compress: false,
|
||||
mangle: false,
|
||||
output: {
|
||||
beautify: true
|
||||
},
|
||||
sourceMap: false,
|
||||
toplevel: false
|
||||
})
|
||||
];
|
||||
|
||||
// List source directory contents
|
||||
const components = fs.readdirSync(source)
|
||||
// Need subdirectories only
|
||||
.filter((item) => {
|
||||
const target = path.join(source, item);
|
||||
const stat = fs.statSync(target);
|
||||
|
||||
return stat.isDirectory();
|
||||
})
|
||||
// Put in order
|
||||
.sort((a, b) => orderOfAppearance.indexOf(a) - orderOfAppearance.indexOf(b))
|
||||
// Prepare an output object for each component module
|
||||
.map((component, _, contents) => ({
|
||||
// So I don't have to specify full paths
|
||||
external: (id) => {
|
||||
// Decompose current component path
|
||||
const segments = id.split('/');
|
||||
|
||||
// Mark as external if contents within source
|
||||
// directory tree, excluding the current component
|
||||
return contents
|
||||
.filter(item => item !== component)
|
||||
.some(item => segments.includes(item));
|
||||
},
|
||||
input: `${source}/${component}/index.js`,
|
||||
// Disable circular dependency warnings
|
||||
onwarn,
|
||||
output: [
|
||||
{
|
||||
file: `${destination}/${component}-${version}.js`,
|
||||
format: 'module',
|
||||
globals: {
|
||||
performance: 'performance'
|
||||
},
|
||||
// Find which module the import points to
|
||||
// and fix path in place
|
||||
paths: (id) => {
|
||||
const name = findName(id, contents);
|
||||
|
||||
return `./${name}-${version}.js`;
|
||||
},
|
||||
sourcemap,
|
||||
},
|
||||
{
|
||||
esModule: false,
|
||||
file: `${destination}/${component}-${version}.iife.js`,
|
||||
format: 'iife',
|
||||
globals: id => findName(id, contents),
|
||||
name: component,
|
||||
paths: (id) => {
|
||||
const name = findName(id, contents);
|
||||
|
||||
return `./${name}-${version}.iife.js`;
|
||||
},
|
||||
sourcemap,
|
||||
plugins: [
|
||||
appender({
|
||||
target: `${destination}/psychojs-${version}.js`,
|
||||
// Mirrors rollup's 'outputOptions' hook
|
||||
outputOptions: (options) => {
|
||||
if (options.file.includes(last)) {
|
||||
options.footer = footer;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
],
|
||||
plugins
|
||||
})
|
||||
);
|
||||
|
||||
export default [
|
||||
...components,
|
||||
{
|
||||
// Add a UMD build for Thomas
|
||||
input: `${source}/index.js`,
|
||||
onwarn,
|
||||
output: {
|
||||
file: `${destination}/psychojs-${version}.umd.js`,
|
||||
format: 'umd',
|
||||
name: 'psychojs'
|
||||
},
|
||||
plugins
|
||||
}
|
||||
];
|
||||
|
||||
// https://rollupjs.org/guide/en/#onwarn
|
||||
function onwarn(message, warn) {
|
||||
// Skip circular dependency warnings
|
||||
if (message.code === 'CIRCULAR_DEPENDENCY') {
|
||||
return;
|
||||
}
|
||||
|
||||
warn(message);
|
||||
}
|
||||
|
||||
// Helper for extracting module name from contents array by rollup id (path to file)
|
||||
function findName(id, contents) {
|
||||
return id.split(path.sep).find(item => contents.includes(item));
|
||||
}
|
||||
|
||||
// Minimal terser plugin
|
||||
function minifier(options) {
|
||||
return {
|
||||
name: 'minifier',
|
||||
async renderChunk(code) {
|
||||
try {
|
||||
// Includes code and map keys
|
||||
const result = await minify(code, options);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Custom plugin for cancatenating IIFE's sans cat(1)
|
||||
function appender({ target = '', outputOptions = () => {} } = {}) {
|
||||
return {
|
||||
name: 'appender',
|
||||
outputOptions: (options) => outputOptions(options),
|
||||
async generateBundle(options, bundle) {
|
||||
const { file } = options;
|
||||
const id = file.split('/').pop();
|
||||
const { code } = bundle[id];
|
||||
|
||||
// Should be expected to throw if `target` missing
|
||||
fs.appendFile(target, code, (error) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent write out
|
||||
delete bundle[id];
|
||||
}
|
||||
};
|
||||
}
|
13
scripts/build.css.cjs
Normal file
13
scripts/build.css.cjs
Normal file
@ -0,0 +1,13 @@
|
||||
const { buildSync } = require('esbuild');
|
||||
const pkg = require('psychojs/package');
|
||||
|
||||
const versionMaybe = process.env.npm_config_outver;
|
||||
const dirMaybe = process.env.npm_config_outdir;
|
||||
const [,,, dir = dirMaybe || 'out', version = versionMaybe || pkg.version] = process.argv;
|
||||
|
||||
buildSync({
|
||||
bundle: true,
|
||||
entryPoints: ['src/index.css'],
|
||||
minify: true,
|
||||
outfile: `./${dir}/psychojs-${version}.css`
|
||||
});
|
14
scripts/build.js.cjs
Normal file
14
scripts/build.js.cjs
Normal file
@ -0,0 +1,14 @@
|
||||
const { buildSync } = require('esbuild');
|
||||
const pkg = require('psychojs/package');
|
||||
|
||||
const versionMaybe = process.env.npm_config_outver;
|
||||
const dirMaybe = process.env.npm_config_outdir;
|
||||
const [,,, dir = dirMaybe || 'out', version = versionMaybe || pkg.version] = process.argv;
|
||||
|
||||
buildSync({
|
||||
bundle: true,
|
||||
entryPoints: ['src/index.js'],
|
||||
format: 'esm',
|
||||
minify: true,
|
||||
outfile: `./${dir}/psychojs-${version}.js`
|
||||
});
|
@ -8,7 +8,7 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
|
||||
import * as Tone from 'tone';
|
||||
import {PsychoJS} from './PsychoJS';
|
||||
import {ServerManager} from './ServerManager';
|
||||
import {Scheduler} from '../util/Scheduler';
|
||||
@ -181,7 +181,7 @@ export class GUI
|
||||
}
|
||||
|
||||
htmlCode += '</select>';
|
||||
$('#' + keyId).selectmenu({classes: {}});
|
||||
jQuery('#' + keyId).selectmenu({classes: {}});
|
||||
}
|
||||
|
||||
// otherwise we use a single string input:
|
||||
@ -209,7 +209,7 @@ export class GUI
|
||||
// the dialog box:
|
||||
if (typeof logoUrl === 'string')
|
||||
{
|
||||
$("#dialog-logo").on('load', () =>
|
||||
jQuery("#dialog-logo").on('load', () =>
|
||||
{
|
||||
self._onDialogOpen('#expDialog')();
|
||||
});
|
||||
@ -231,7 +231,7 @@ export class GUI
|
||||
self._dialogComponent.button = 'Cancel';
|
||||
self._estimateDialogScalingFactor();
|
||||
const dialogSize = self._getDialogSize();
|
||||
$("#expDialog").dialog({
|
||||
jQuery("#expDialog").dialog({
|
||||
width: dialogSize[0],
|
||||
maxHeight: dialogSize[1],
|
||||
|
||||
@ -248,7 +248,7 @@ export class GUI
|
||||
click: function ()
|
||||
{
|
||||
self._dialogComponent.button = 'Cancel';
|
||||
$("#expDialog").dialog('close');
|
||||
jQuery("#expDialog").dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -270,7 +270,7 @@ export class GUI
|
||||
|
||||
|
||||
self._dialogComponent.button = 'OK';
|
||||
$("#expDialog").dialog('close');
|
||||
jQuery("#expDialog").dialog('close');
|
||||
|
||||
// Tackle browser demands on having user action initiate audio context
|
||||
Tone.start();
|
||||
@ -290,8 +290,8 @@ export class GUI
|
||||
// close is called by both buttons and when the user clicks on the cross:
|
||||
close: function ()
|
||||
{
|
||||
//$.unblockUI();
|
||||
$(this).dialog('destroy').remove();
|
||||
//jQuery.unblockUI();
|
||||
jQuery(this).dialog('destroy').remove();
|
||||
self._dialogComponent.status = PsychoJS.Status.FINISHED;
|
||||
}
|
||||
|
||||
@ -310,11 +310,11 @@ export class GUI
|
||||
|
||||
// block UI until user has pressed dialog button:
|
||||
// note: block UI does not allow for text to be entered in the dialog form boxes, alas!
|
||||
//$.blockUI({ message: "", baseZ: 1});
|
||||
//jQuery.blockUI({ message: "", baseZ: 1});
|
||||
|
||||
// show dialog box:
|
||||
$("#progressbar").progressbar({value: self._progressBarCurrentValue});
|
||||
$("#progressbar").progressbar("option", "max", self._progressBarMax);
|
||||
jQuery("#progressbar").progressbar({value: self._progressBarCurrentValue});
|
||||
jQuery("#progressbar").progressbar("option", "max", self._progressBarMax);
|
||||
}
|
||||
|
||||
if (self._dialogComponent.status === PsychoJS.Status.FINISHED)
|
||||
@ -357,12 +357,12 @@ export class GUI
|
||||
{
|
||||
|
||||
// close the previously opened dialog box, if there is one:
|
||||
const expDialog = $("#expDialog");
|
||||
const expDialog = jQuery("#expDialog");
|
||||
if (expDialog.length)
|
||||
{
|
||||
expDialog.dialog("destroy").remove();
|
||||
}
|
||||
const msgDialog = $("#msgDialog");
|
||||
const msgDialog = jQuery("#msgDialog");
|
||||
if (msgDialog.length)
|
||||
{
|
||||
msgDialog.dialog("destroy").remove();
|
||||
@ -459,7 +459,7 @@ export class GUI
|
||||
this._estimateDialogScalingFactor();
|
||||
const dialogSize = this._getDialogSize();
|
||||
const self = this;
|
||||
$("#msgDialog").dialog({
|
||||
jQuery("#msgDialog").dialog({
|
||||
dialogClass: 'no-close',
|
||||
|
||||
width: dialogSize[0],
|
||||
@ -476,7 +476,7 @@ export class GUI
|
||||
text: "Ok",
|
||||
click: function ()
|
||||
{
|
||||
$(this).dialog("destroy").remove();
|
||||
jQuery(this).dialog("destroy").remove();
|
||||
|
||||
// execute callback function:
|
||||
if (typeof onOK !== 'undefined')
|
||||
@ -514,10 +514,10 @@ export class GUI
|
||||
|
||||
return () =>
|
||||
{
|
||||
const windowSize = [$(window).width(), $(window).height()];
|
||||
const windowSize = [jQuery(window).width(), jQuery(window).height()];
|
||||
|
||||
// note: $(dialogId) is the dialog-content, $(dialogId).parent() is the actual widget
|
||||
const parent = $(dialogId).parent();
|
||||
// note: jQuery(dialogId) is the dialog-content, jQuery(dialogId).parent() is the actual widget
|
||||
const parent = jQuery(dialogId).parent();
|
||||
parent.css({
|
||||
position: 'absolute',
|
||||
left: Math.max(0, (windowSize[0] - parent.outerWidth()) / 2.0),
|
||||
@ -526,8 +526,8 @@ export class GUI
|
||||
|
||||
// record width and height difference between dialog content and dialog:
|
||||
self._contentDelta = [
|
||||
parent.css('width').slice(0, -2) - $(dialogId).css('width').slice(0, -2),
|
||||
parent.css('height').slice(0, -2) - $(dialogId).css('height').slice(0, -2)];
|
||||
parent.css('width').slice(0, -2) - jQuery(dialogId).css('width').slice(0, -2),
|
||||
parent.css('height').slice(0, -2) - jQuery(dialogId).css('height').slice(0, -2)];
|
||||
};
|
||||
}
|
||||
|
||||
@ -544,10 +544,10 @@ export class GUI
|
||||
{
|
||||
const self = this;
|
||||
|
||||
$(window).resize(function ()
|
||||
jQuery(window).resize(function ()
|
||||
{
|
||||
const parent = $(dialogId).parent();
|
||||
const windowSize = [$(window).width(), $(window).height()];
|
||||
const parent = jQuery(dialogId).parent();
|
||||
const windowSize = [jQuery(window).width(), jQuery(window).height()];
|
||||
|
||||
// size (we need to redimension both the dialog and the dialog content):
|
||||
const dialogSize = self._getDialogSize();
|
||||
@ -559,7 +559,7 @@ export class GUI
|
||||
const isDifferent = self._estimateDialogScalingFactor();
|
||||
if (!isDifferent)
|
||||
{
|
||||
$(dialogId).css({
|
||||
jQuery(dialogId).css({
|
||||
width: dialogSize[0] - self._contentDelta[0],
|
||||
maxHeight: dialogSize[1] - self._contentDelta[1]
|
||||
});
|
||||
@ -592,7 +592,7 @@ export class GUI
|
||||
{
|
||||
// for each resource, we have a 'downloading resource' and a 'resource downloaded' message:
|
||||
this._progressBarMax = signal.count * 2;
|
||||
$("#progressbar").progressbar("option", "max", this._progressBarMax);
|
||||
jQuery("#progressbar").progressbar("option", "max", this._progressBarMax);
|
||||
|
||||
this._progressBarCurrentValue = 0;
|
||||
}
|
||||
@ -601,7 +601,7 @@ export class GUI
|
||||
else if (signal.message === ServerManager.Event.DOWNLOAD_COMPLETED)
|
||||
{
|
||||
this._allResourcesDownloaded = true;
|
||||
$("#progressMsg").text('all resources downloaded.');
|
||||
jQuery("#progressMsg").text('all resources downloaded.');
|
||||
this._updateOkButtonStatus();
|
||||
}
|
||||
|
||||
@ -617,20 +617,20 @@ export class GUI
|
||||
|
||||
if (signal.message === ServerManager.Event.RESOURCE_DOWNLOADED)
|
||||
{
|
||||
$("#progressMsg").text('downloaded ' + (this._progressBarCurrentValue / 2) + ' / ' + (this._progressBarMax / 2));
|
||||
jQuery("#progressMsg").text('downloaded ' + (this._progressBarCurrentValue / 2) + ' / ' + (this._progressBarMax / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#progressMsg").text('downloading ' + (this._progressBarCurrentValue / 2) + ' / ' + (this._progressBarMax / 2));
|
||||
jQuery("#progressMsg").text('downloading ' + (this._progressBarCurrentValue / 2) + ' / ' + (this._progressBarMax / 2));
|
||||
}
|
||||
// $("#progressMsg").text(signal.resource + ': downloaded.');
|
||||
$("#progressbar").progressbar("option", "value", this._progressBarCurrentValue);
|
||||
jQuery("#progressbar").progressbar("option", "value", this._progressBarCurrentValue);
|
||||
}
|
||||
|
||||
// unknown message: we just display it
|
||||
else
|
||||
{
|
||||
$("#progressMsg").text(signal.message);
|
||||
jQuery("#progressMsg").text(signal.message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -649,23 +649,23 @@ export class GUI
|
||||
{
|
||||
if (changeFocus)
|
||||
{
|
||||
$("#buttonOk").button("option", "disabled", false).focus();
|
||||
jQuery("#buttonOk").button("option", "disabled", false).focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#buttonOk").button("option", "disabled", false);
|
||||
jQuery("#buttonOk").button("option", "disabled", false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#buttonOk").button("option", "disabled", true);
|
||||
jQuery("#buttonOk").button("option", "disabled", true);
|
||||
}
|
||||
|
||||
// strangely, changing the disabled option sometimes fails to update the ui,
|
||||
// so we need to hide it and show it again:
|
||||
$("#buttonOk").hide(0, () =>
|
||||
jQuery("#buttonOk").hide(0, () =>
|
||||
{
|
||||
$("#buttonOk").show();
|
||||
jQuery("#buttonOk").show();
|
||||
});
|
||||
}
|
||||
|
||||
@ -680,7 +680,7 @@ export class GUI
|
||||
*/
|
||||
_estimateDialogScalingFactor()
|
||||
{
|
||||
const windowSize = [$(window).width(), $(window).height()];
|
||||
const windowSize = [jQuery(window).width(), jQuery(window).height()];
|
||||
|
||||
// desktop:
|
||||
let dialogScalingFactor = 1.0;
|
||||
@ -715,7 +715,7 @@ export class GUI
|
||||
*/
|
||||
_getDialogSize()
|
||||
{
|
||||
const windowSize = [$(window).width(), $(window).height()];
|
||||
const windowSize = [jQuery(window).width(), jQuery(window).height()];
|
||||
this._estimateDialogScalingFactor();
|
||||
|
||||
return [
|
||||
|
@ -8,11 +8,12 @@
|
||||
*/
|
||||
|
||||
|
||||
import log4javascript from 'log4javascript';
|
||||
import pako from 'pako';
|
||||
import * as util from '../util/Util';
|
||||
import {MonotonicClock} from '../util/Clock';
|
||||
import {ExperimentHandler} from '../data/ExperimentHandler';
|
||||
|
||||
|
||||
/**
|
||||
* <p>This class handles a variety of loggers, e.g. a browser console one (mostly for debugging),
|
||||
* a remote one, etc.</p>
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
|
||||
import log4javascript from 'log4javascript';
|
||||
import {Scheduler} from '../util/Scheduler';
|
||||
import {ServerManager} from './ServerManager';
|
||||
import {ExperimentHandler} from '../data/ExperimentHandler';
|
||||
@ -182,7 +182,7 @@ export class PsychoJS
|
||||
this.logger.info('[PsychoJS] @version 2021.1.4');
|
||||
|
||||
// Hide #root::after
|
||||
$('#root').addClass('is-ready');
|
||||
jQuery('#root').addClass('is-ready');
|
||||
}
|
||||
|
||||
|
||||
@ -696,7 +696,7 @@ export class PsychoJS
|
||||
this._IP = {};
|
||||
try
|
||||
{
|
||||
const geoResponse = await $.get('http://www.geoplugin.net/json.gp');
|
||||
const geoResponse = await jQuery.get('http://www.geoplugin.net/json.gp');
|
||||
const geoData = JSON.parse(geoResponse);
|
||||
this._IP = {
|
||||
IP: geoData.geoplugin_request,
|
||||
|
@ -7,15 +7,14 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
|
||||
import createjs from 'preload-js';
|
||||
import { Howl } from 'howler';
|
||||
import {PsychoJS} from './PsychoJS';
|
||||
import {PsychObject} from '../util/PsychObject';
|
||||
import * as util from '../util/Util';
|
||||
import {ExperimentHandler} from "../data/ExperimentHandler";
|
||||
import {MonotonicClock} from "../util/Clock";
|
||||
|
||||
// import { Howl } from 'howler';
|
||||
|
||||
|
||||
/**
|
||||
* <p>This manager handles all communications between the experiment running in the participant's browser and the [pavlovia.org]{@link http://pavlovia.org} server, <em>in an asynchronous manner</em>.</p>
|
||||
@ -87,7 +86,7 @@ export class ServerManager extends PsychObject
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
$.get(configURL, 'json')
|
||||
jQuery.get(configURL, 'json')
|
||||
.done((config, textStatus) =>
|
||||
{
|
||||
// resolve({ ...response, config });
|
||||
@ -144,7 +143,7 @@ export class ServerManager extends PsychObject
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
const url = this._psychoJS.config.pavlovia.URL + '/api/v2/experiments/' + encodeURIComponent(self._psychoJS.config.experiment.fullpath) + '/sessions';
|
||||
$.post(url, data, null, 'json')
|
||||
jQuery.post(url, data, null, 'json')
|
||||
.done((data, textStatus) =>
|
||||
{
|
||||
if (!('token' in data))
|
||||
@ -246,7 +245,7 @@ export class ServerManager extends PsychObject
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
$.ajax({
|
||||
jQuery.ajax({
|
||||
url,
|
||||
type: 'delete',
|
||||
data: {isCompleted},
|
||||
@ -669,7 +668,7 @@ export class ServerManager extends PsychObject
|
||||
value
|
||||
};
|
||||
|
||||
$.post(url, data, null, 'json')
|
||||
jQuery.post(url, data, null, 'json')
|
||||
.done((serverData, textStatus) =>
|
||||
{
|
||||
self.setStatus(ServerManager.Status.READY);
|
||||
@ -731,7 +730,7 @@ export class ServerManager extends PsychObject
|
||||
'/sessions/' + self._psychoJS.config.session.token +
|
||||
'/logs';
|
||||
|
||||
$.post(url, data, null, 'json')
|
||||
jQuery.post(url, data, null, 'json')
|
||||
.done((serverData, textStatus) =>
|
||||
{
|
||||
self.setStatus(ServerManager.Status.READY);
|
||||
@ -860,7 +859,7 @@ export class ServerManager extends PsychObject
|
||||
'/api/v2/experiments/' + encodeURIComponent(this._psychoJS.config.experiment.fullpath) +
|
||||
'/resources';
|
||||
|
||||
$.get(url, data, null, 'json')
|
||||
jQuery.get(url, data, null, 'json')
|
||||
.done((data, textStatus) =>
|
||||
{
|
||||
if (!('resources' in data))
|
||||
|
@ -7,6 +7,7 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {Color} from '../util/Color';
|
||||
import {PsychObject} from '../util/PsychObject';
|
||||
import {MonotonicClock} from '../util/Clock';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as XLSX from 'xlsx';
|
||||
import {PsychObject} from '../util/PsychObject';
|
||||
import {MonotonicClock} from '../util/Clock';
|
||||
import * as util from '../util/Util';
|
||||
|
@ -10,10 +10,11 @@
|
||||
*/
|
||||
|
||||
|
||||
import seedrandom from 'seedrandom';
|
||||
import * as XLSX from 'xlsx';
|
||||
import {PsychObject} from '../util/PsychObject';
|
||||
import * as util from '../util/Util';
|
||||
|
||||
|
||||
/**
|
||||
* <p>A Trial Handler handles the importing and sequencing of conditions.</p>
|
||||
*
|
||||
@ -618,11 +619,11 @@ export class TrialHandler extends PsychObject
|
||||
// seed the random number generator:
|
||||
if (typeof (this.seed) !== 'undefined')
|
||||
{
|
||||
Math.seedrandom(this.seed);
|
||||
seedrandom(this.seed);
|
||||
}
|
||||
else
|
||||
{
|
||||
Math.seedrandom();
|
||||
seedrandom();
|
||||
}
|
||||
|
||||
if (this.method === TrialHandler.Method.SEQUENTIAL)
|
||||
|
@ -7,6 +7,7 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
import * as Tone from 'tone';
|
||||
import {SoundPlayer} from './SoundPlayer';
|
||||
|
||||
|
||||
@ -243,7 +244,7 @@ export class TonePlayer extends SoundPlayer
|
||||
playToneCallback,
|
||||
this.duration_s,
|
||||
Tone.now(),
|
||||
Tone.Infinity
|
||||
Infinity
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -7,6 +7,8 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
/**
|
||||
* <p>MonotonicClock offers a convenient way to keep track of time during experiments. An experiment can have as many independent clocks as needed, e.g. one to time responses, another one to keep track of stimuli, etc.</p>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* @license Distributed under the terms of the MIT License
|
||||
*/
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
|
||||
|
||||
/**
|
||||
* Syntactic sugar for Mixins
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
import * as util from '../util/Util';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -9,6 +9,8 @@
|
||||
* We are currently using it almost as is but will be making modification in the near future.
|
||||
*/
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
|
||||
export class TextInput extends PIXI.Container
|
||||
{
|
||||
constructor(styles)
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {VisualStim} from './VisualStim';
|
||||
import {Color} from '../util/Color';
|
||||
import {ColorMixin} from '../util/ColorMixin';
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as PIXI from 'pixi.js-legacy';
|
||||
import {MinimalStim} from '../core/MinimalStim';
|
||||
import {WindowMixin} from '../core/WindowMixin';
|
||||
import * as util from '../util/Util';
|
||||
|
Loading…
Reference in New Issue
Block a user