jspsych-vue
Advanced tools
@@ -1,7 +0,7 @@ | ||
var q = Object.defineProperty; | ||
var J = (t, n, s) => n in t ? q(t, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[n] = s; | ||
var M = Object.defineProperty; | ||
var J = (t, n, s) => n in t ? M(t, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[n] = s; | ||
var w = (t, n, s) => J(t, typeof n != "symbol" ? n + "" : n, s); | ||
import { shallowRef as L, ref as E, provide as N, getCurrentInstance as I, h as l, onMounted as A } from "vue"; | ||
import { shallowRef as L, ref as E, provide as N, getCurrentInstance as I, h as l, nextTick as A } from "vue"; | ||
import { nanoid as S } from "nanoid"; | ||
const m = (t = void 0, n = "100%", s = void 0) => ({ | ||
const h = (t = void 0, n = "100%", s = void 0) => ({ | ||
name: "JsPsychContent", | ||
@@ -20,3 +20,3 @@ props: { | ||
return A(() => { | ||
s && s(document.querySelector("jspsych-content"), i.trial, i.on_load); | ||
s && s(document.querySelector("#jspsych-content"), i.trial, i.on_load); | ||
}), () => { | ||
@@ -32,3 +32,3 @@ let p; | ||
} | ||
}), H = (t) => { | ||
}), k = (t) => { | ||
if (!t) | ||
@@ -60,6 +60,7 @@ return document.body; | ||
const s = "jsPsychModule" in window ? window.jsPsychModule : t.module; | ||
s || console.error("JsPsych module is not found. You can either install it using npm, then passing it as module prop to JsPsychVue component or use CDN to load it."); | ||
const { JsPsych: i, initJsPsych: p } = s, a = L(), h = E(), f = E(); | ||
if (!s) | ||
throw Error("JsPsych module is not found. You can either install it using npm, then passing it as module prop to JsPsychVue component or use CDN to load it."); | ||
const { JsPsych: i, initJsPsych: p } = s, a = L(), m = E(), f = E(); | ||
i.prototype.prepareDom = function() { | ||
let e = H(t.options.display_element); | ||
let e = k(t.options.display_element); | ||
this.displayContainerElement = e, this.DOM_container = this.displayContainerElement, this.contentElement = document.querySelector("#jspsych-content"), this.DOM_target = this.contentElement, this.displayElement = this.contentElement, this.data.createInteractionListeners(), window.addEventListener("beforeunload", t.options.on_close); | ||
@@ -79,3 +80,3 @@ }; | ||
g.on_finish = (...o) => { | ||
e && e.call(this, ...o), a.value = m(j, c); | ||
e && e.call(this, ...o), a.value = h(j, c); | ||
}; | ||
@@ -88,3 +89,3 @@ } | ||
const C = n.start && n.start() || n.default && n.default(); | ||
a.value = m(C, c); | ||
a.value = h(C, c); | ||
const b = (e) => { | ||
@@ -98,5 +99,5 @@ if (e.type && e.component) | ||
trial(B, O, P) { | ||
h.value = O, f.value = P; | ||
const x = (...M) => super.trial && super.trial.call(this, ...M); | ||
a.value = m(e.component, c, x), console.log(a.value); | ||
m.value = O, f.value = P; | ||
const x = (...q) => super.trial && super.trial.call(this, ...q); | ||
a.value = h(e.component, c, x); | ||
} | ||
@@ -126,3 +127,3 @@ } | ||
var o = e.format || "json"; | ||
o = o.toLowerCase(), o != "json" && o != "csv" && (console.log("Invalid format declared for displayData function. Using json as default."), o = "json"); | ||
o = o.toLowerCase(), o != "json" && o != "csv" && (console.error("Invalid format declared for displayData function. Using json as default."), o = "json"); | ||
let u = r.data.allData ? r.data.allData : r.data.results; | ||
@@ -138,3 +139,3 @@ const y = o === "json" ? u.json(!0) : u.csv(); | ||
class: "jspsych-content-wrapper" | ||
}, l(a.value, { trial: h.value, on_load: f.value }))); | ||
}, l(a.value, { trial: m.value, on_load: f.value }))); | ||
} | ||
@@ -141,0 +142,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
(function(t,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue"),require("nanoid")):typeof define=="function"&&define.amd?define(["vue","nanoid"],o):(t=typeof globalThis<"u"?globalThis:t||self,t["vue-jspsych"]=o(t.Vue,t.nanoid))})(this,function(t,o){"use strict";var J=Object.defineProperty;var L=(t,o,a)=>o in t?J(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a;var E=(t,o,a)=>L(t,typeof o!="symbol"?o+"":o,a);const a=(n=void 0,i="100%",p=void 0)=>({name:"JsPsychContent",props:{trial:{type:Object,required:!1},on_load:{type:Function,required:!1}},setup(r){return t.onMounted(()=>{p&&p(document.querySelector("jspsych-content"),r.trial,r.on_load)}),()=>{let u;return Array.isArray(n)?u=n.map(d=>t.h(d)):u=n&&t.h(n,{key:o.nanoid(),...r}),t.h("div",{class:"jspsych-content",id:"jspsych-content",tabIndex:"0",style:`width: ${i};`},u)}}}),v=n=>{if(!n)return document.body;if(n instanceof Element)return n;if(typeof n=="string"){const i=document.querySelector(n);if(!i)throw Error("The element with the specified selector does not exist.");return i}throw Error("Display element must be an HTML element or a string that specifies a query selector.")};return{name:"JsPsych",props:{options:{type:Object,default:()=>({})},module:{type:Object,required:!1}},emits:["init"],setup(n,{slots:i}){const p="jsPsychModule"in window?window.jsPsychModule:n.module;p||console.error("JsPsych module is not found. You can either install it using npm, then passing it as module prop to JsPsychVue component or use CDN to load it.");const{JsPsych:r,initJsPsych:u}=p,d=t.shallowRef(),m=t.ref(),j=t.ref();r.prototype.prepareDom=function(){let e=v(n.options.display_element);this.displayContainerElement=e,this.DOM_container=this.displayContainerElement,this.contentElement=document.querySelector("#jspsych-content"),this.DOM_target=this.contentElement,this.displayElement=this.contentElement,this.data.createInteractionListeners(),window.addEventListener("beforeunload",n.options.on_close)};var T=r.prototype.run;r.prototype.run=function(e){return T.call(this,y(e))};var g=r.prototype.addNodeToEndOfTimeline;r.prototype.addNodeToEndOfTimeline=function(e){return g.call(this,y(e))};const w=i.finish&&i.finish()||i.default&&i.default(),C=n.options;if(w){const e=n.options.on_finish;C.on_finish=(...s)=>{e&&e.call(this,...s),d.value=a(w,l)}}const c=u(n.options);t.provide("jsPsych",c),t.getCurrentInstance().emit("init",c);let l=(c.options||c.opts).experiment_width||"100%";typeof l=="number"&&(l=`${l}px`);const D=i.start&&i.start()||i.default&&i.default();d.value=a(D,l);const O=e=>{if(e.type&&e.component)throw new Error("Cannot specify both type and component in a single timeline node.");if(!e.type&&!e.component)throw new Error("Must specify either type or component in a timeline node.");const s=e.type||Object,f=e.component?e.component.info||{}:{};class h extends s{trial(S,b,q){m.value=b,j.value=q;const x=(...M)=>super.trial&&super.trial.call(this,...M);d.value=a(e.component,l,x),console.log(d.value)}}E(h,"info",{...s.info,...f});const{component:_,...P}=e;return{...P,type:h}},y=e=>{if(!e)throw Error("Try to convert an empty timeline. Do you forget add the plugin?");if(e.type||e.component)return O(e);if(Array.isArray(e))return e.map(s=>y(s));if(!e.timeline)throw Error("TimelineNode expected one of the following property that is not undifined: timeline, type, component.");return{...e,timeline:y(e.timeline)}};return c.data.displayData=e=>{var s=e.format||"json";s=s.toLowerCase(),s!="json"&&s!="csv"&&(console.log("Invalid format declared for displayData function. Using json as default."),s="json");let f=c.data.allData?c.data.allData:c.data.results;const h=s==="json"?f.json(!0):f.csv();var _=e.dom||document.querySelector("#jspsych-display-element");_.innerHTML='<pre id="jspsych-data-display"></pre>',document.getElementById("jspsych-data-display").textContent=h},()=>t.h("div",{id:"jspsych-display-element",class:"jspsych-display-element"},t.h("div",{id:"jspsych-content-wrapper",class:"jspsych-content-wrapper"},t.h(d.value,{trial:m.value,on_load:j.value})))}}}); | ||
(function(t,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue"),require("nanoid")):typeof define=="function"&&define.amd?define(["vue","nanoid"],o):(t=typeof globalThis<"u"?globalThis:t||self,t["vue-jspsych"]=o(t.Vue,t.nanoid))})(this,function(t,o){"use strict";var J=Object.defineProperty;var L=(t,o,a)=>o in t?J(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a;var _=(t,o,a)=>L(t,typeof o!="symbol"?o+"":o,a);const a=(n=void 0,i="100%",p=void 0)=>({name:"JsPsychContent",props:{trial:{type:Object,required:!1},on_load:{type:Function,required:!1}},setup(r){return t.nextTick(()=>{p&&p(document.querySelector("#jspsych-content"),r.trial,r.on_load)}),()=>{let u;return Array.isArray(n)?u=n.map(d=>t.h(d)):u=n&&t.h(n,{key:o.nanoid(),...r}),t.h("div",{class:"jspsych-content",id:"jspsych-content",tabIndex:"0",style:`width: ${i};`},u)}}}),T=n=>{if(!n)return document.body;if(n instanceof Element)return n;if(typeof n=="string"){const i=document.querySelector(n);if(!i)throw Error("The element with the specified selector does not exist.");return i}throw Error("Display element must be an HTML element or a string that specifies a query selector.")};return{name:"JsPsych",props:{options:{type:Object,default:()=>({})},module:{type:Object,required:!1}},emits:["init"],setup(n,{slots:i}){const p="jsPsychModule"in window?window.jsPsychModule:n.module;if(!p)throw Error("JsPsych module is not found. You can either install it using npm, then passing it as module prop to JsPsychVue component or use CDN to load it.");const{JsPsych:r,initJsPsych:u}=p,d=t.shallowRef(),m=t.ref(),j=t.ref();r.prototype.prepareDom=function(){let e=T(n.options.display_element);this.displayContainerElement=e,this.DOM_container=this.displayContainerElement,this.contentElement=document.querySelector("#jspsych-content"),this.DOM_target=this.contentElement,this.displayElement=this.contentElement,this.data.createInteractionListeners(),window.addEventListener("beforeunload",n.options.on_close)};var v=r.prototype.run;r.prototype.run=function(e){return v.call(this,y(e))};var C=r.prototype.addNodeToEndOfTimeline;r.prototype.addNodeToEndOfTimeline=function(e){return C.call(this,y(e))};const w=i.finish&&i.finish()||i.default&&i.default(),x=n.options;if(w){const e=n.options.on_finish;x.on_finish=(...s)=>{e&&e.call(this,...s),d.value=a(w,l)}}const c=u(n.options);t.provide("jsPsych",c),t.getCurrentInstance().emit("init",c);let l=(c.options||c.opts).experiment_width||"100%";typeof l=="number"&&(l=`${l}px`);const D=i.start&&i.start()||i.default&&i.default();d.value=a(D,l);const O=e=>{if(e.type&&e.component)throw new Error("Cannot specify both type and component in a single timeline node.");if(!e.type&&!e.component)throw new Error("Must specify either type or component in a timeline node.");const s=e.type||Object,h=e.component?e.component.info||{}:{};class f extends s{trial(S,b,g){m.value=b,j.value=g;const q=(...M)=>super.trial&&super.trial.call(this,...M);d.value=a(e.component,l,q)}}_(f,"info",{...s.info,...h});const{component:E,...P}=e;return{...P,type:f}},y=e=>{if(!e)throw Error("Try to convert an empty timeline. Do you forget add the plugin?");if(e.type||e.component)return O(e);if(Array.isArray(e))return e.map(s=>y(s));if(!e.timeline)throw Error("TimelineNode expected one of the following property that is not undifined: timeline, type, component.");return{...e,timeline:y(e.timeline)}};return c.data.displayData=e=>{var s=e.format||"json";s=s.toLowerCase(),s!="json"&&s!="csv"&&(console.error("Invalid format declared for displayData function. Using json as default."),s="json");let h=c.data.allData?c.data.allData:c.data.results;const f=s==="json"?h.json(!0):h.csv();var E=e.dom||document.querySelector("#jspsych-display-element");E.innerHTML='<pre id="jspsych-data-display"></pre>',document.getElementById("jspsych-data-display").textContent=f},()=>t.h("div",{id:"jspsych-display-element",class:"jspsych-display-element"},t.h("div",{id:"jspsych-content-wrapper",class:"jspsych-content-wrapper"},t.h(d.value,{trial:m.value,on_load:j.value})))}}}); |
{ | ||
"name": "jspsych-vue", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "Vue3 component for JsPsych", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
159
0.63%0
-100%30061
-0.23%