@adriansteffan/reactive 0.1.34 → 0.1.36

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.
@@ -1,4 +1,4 @@
1
- import { H as e, C as t, a as i, D as r, c as n, d as o, e as l, f as m, g as u, Y as c, z as p, M as P, P as g, h as T, i as C, Q as D, R as d, j as S, k as h, F as x, T as E, l as f, m as k, n as v, o as B, U as F, X as A, p as R, q as _, r as I, s as K, t as M, u as b, v as y, w as L, x as U, y as w, A as G, B as q, G as H, I as N, J as Q, K as Z, L as j, N as z, O as J, S as O, V, Z as X, _ as Y, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua, ac as ca, ad as pa, ae as Pa, af as ga, ag as Ta, ah as Ca, ai as Da } from "./mod-BpIlYaYt.js";
1
+ import { H as e, C as t, a as i, D as r, c as n, d as o, e as l, f as m, g as u, Y as c, z as p, M as P, P as g, h as T, i as C, Q as D, R as d, j as S, k as h, F as x, T as E, l as f, m as k, n as v, o as B, U as F, X as A, p as R, q as _, r as I, s as K, t as M, u as b, v as y, w as L, x as U, y as w, A as G, B as q, G as H, I as N, J as Q, K as Z, L as j, N as z, O as J, S as O, V, Z as X, _ as Y, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua, ac as ca, ad as pa, ae as Pa, af as ga, ag as Ta, ah as Ca, ai as Da } from "./mod-urua6TFn.js";
2
2
  export {
3
3
  e as Bounce,
4
4
  t as CanvasBlock,
@@ -10149,7 +10149,7 @@
10149
10149
  `),u.length>0){console.error(`
10150
10150
  ${u.length} participant(s) failed:`);for(const{index:f,error:y}of u)console.error(` Participant ${f}: ${y}`)}console.log(`Simulation complete. ${l-u.length}/${n} participants simulated successfully.`)}finally{a.kill(),console.log("Backend stopped.")}}const ic={};function ui(i,e,t){ic[i]||(ic[i]=[]),ic[i].push({csv:e,flatten:t})}function Ow(i){const e=i.responseData;return Array.isArray(e)?e.map(t=>({block:i.name,...t})):[]}function Mw(i){if(i==null)return"";const e=String(i);return e.includes(",")||e.includes('"')||e.includes(`
10151
10151
  `)?`"${e.replace(/"/g,'""')}"`:e}function rc(i){if(!i||i.length===0)return"";const e=new Set;i.forEach(n=>{Object.keys(n).forEach(a=>{e.add(a)})});const t=Array.from(e),s=t.map(n=>Mw(n)).join(","),r=i.map(n=>t.map(a=>{const o=n[a];return Mw(o)}).join(","));return[s,...r].join(`
10152
- `)}function cne(i){var s,r;const e=(r=(s=i==null?void 0:i[0])==null?void 0:s.responseData)==null?void 0:r.params;if(!e||typeof e!="object")return{};const t={};for(const[n,a]of Object.entries(e))a&&typeof a=="object"&&(t[n]=a.value??a.defaultValue);return t}const Nw=new Set(["index","trialNumber","start","end","duration","type","name","csv","responseData","metadata"]),dne=new Set(["index","trialNumber","start","end","duration","type","name"]);function pne(i,e,t){var a,o;const s=[],r={};for(const l of e){if(l.index===-1)continue;const u=l.csv,h=u?(Array.isArray(u)?u:[u]).map(c=>({csv:c})):ic[l.type]??[];for(const c of h)c.csv&&(r[c.csv]||(r[c.csv]=[]),r[c.csv].push({item:l,flatten:"flatten"in c?c.flatten:void 0}))}const n={sessionID:i,userAgent:(o=(a=e==null?void 0:e[0])==null?void 0:a.responseData)==null?void 0:o.userAgent,...cne(e),...t};if(r.session){for(const{item:l}of r.session){const u=l.name||l.type;for(const[h,c]of Object.entries(l))Nw.has(h)||(n[`${u}_${h}`]=c);if(l.responseData&&typeof l.responseData=="object"&&!Array.isArray(l.responseData))for(const[h,c]of Object.entries(l.responseData))n[`${u}_${h}`]=c}delete r.session}Object.keys(n).length>1&&s.push({filename:`session.${i}.${Date.now()}.csv`,content:rc([n]),encoding:"utf8"});for(const[l,u]of Object.entries(r)){const h=u.flatMap(({item:c,flatten:d})=>{const f={};for(const[v,m]of Object.entries(c))Nw.has(v)?dne.has(v)&&(f[`trial_${v}`]=m):f[v]=m;return(d?d(c):[c.responseData&&typeof c.responseData=="object"?{...c.responseData}:{}]).map(v=>({...f,...v}))});h.length>0&&s.push({filename:`${l}.${i}.${Date.now()}.csv`,content:rc(h),encoding:"utf8"})}return s}function Fw(i){const{sessionID:e,data:t,store:s,generateFiles:r,sessionData:n,uploadRaw:a=!0}=i,o=r?r(e,t,s):[];return a&&o.push({filename:`${e}.raw.json`,content:JSON.stringify(t),encoding:"utf8"}),o.push(...pne(e,t,n)),o}const xm=V.createContext("light"),_n=()=>V.useContext(xm),qw={text:"text-[#f5f5f5]",prose:"prose-invert",proseLink:"prose-a:text-blue-400",buttonBg:"bg-white",buttonText:"text-black",buttonBorder:"border-black",buttonShadow:"shadow-[2px_2px_0px_rgba(0,0,0,1)]",buttonDisabledBg:"bg-gray-700",buttonDisabledText:"text-gray-500",buttonDisabledBorder:"border-gray-600",buttonDisabledShadow:"shadow-[2px_2px_0px_rgba(75,85,99,1)]",error:"text-red-400",focusRing:"focus:ring-blue-400",inputBg:"bg-gray-700",inputBorder:"border-gray-500",inputText:"text-[#f5f5f5]",progressBg:"bg-gray-700",progressStripe1:"#374151",progressStripe2:"#4B5563",dotActive:"#fff",dotInactive:"rgba(255,255,255,0.3)",toastTheme:"dark"},Bw={light:{containerBg:"",text:"text-black",prose:"prose-slate",proseLink:"prose-a:text-blue-600",buttonBg:"bg-white",buttonText:"text-black",buttonBorder:"border-black",buttonShadow:"shadow-[2px_2px_0px_rgba(0,0,0,1)]",buttonDisabledBg:"bg-gray-200",buttonDisabledText:"text-gray-400",buttonDisabledBorder:"border-gray-400",buttonDisabledShadow:"shadow-[2px_2px_0px_rgba(156,163,175,1)]",error:"text-red-500",focusRing:"focus:ring-blue-500",inputBg:"",inputBorder:"border-black",inputText:"",progressBg:"bg-gray-200",progressStripe1:"#E5E7EB",progressStripe2:"#D1D5DB",dotActive:"#000",dotInactive:"rgba(0,0,0,0.2)",toastTheme:"light"},dark:{containerBg:"reactive-dark-bg",...qw},"dark-plain":{containerBg:"reactive-dark-bg-plain",...qw}},fne="reactive-dark-bg",mne="reactive-dark-bg-plain";function Jr(i){return Bw[i]}function nc(i){return typeof i=="number"?i:i.type==="normal"?Y.normal(i.mean,i.sd):Y.uniform(i.min,i.max)}function $w(i){return Math.max(0,nc(i))}function Hw(i){const e=i.dt??1,t=Math.sqrt(e),s=nc(i.startingPoint);if(i.contaminationRate&&Y.uniform(0,1)<i.contaminationRate)return{choice:Y.uniform(0,1)<.5?0:1,rt:Y.uniform(0,i.timeLimit),finalEvidence:s,isContaminated:!0};const r=nc(i.driftRate),n=Math.max(0,nc(i.noiseLevel)),a=i.sensoryDelay!=null?$w(i.sensoryDelay):0,o=i.motorDelay!=null?$w(i.motorDelay):0;let l,u;Array.isArray(i.boundaries)?(u=i.boundaries[0],l=i.boundaries[1]):(l=i.boundaries,u=-i.boundaries);let h=a,c=s,d=!1,f=null;for(;h<i.timeLimit;){h+=e;let v=r,m=n;if(h<=i.stimOffset)i.stimulusCollapse&&h-a>(i.stimulusCollapse.delay??0)&&(l-=i.stimulusCollapse.rate*e,u+=i.stimulusCollapse.rate*e);else{const g=i.postStimStrategy;if(g.type==="snapshot"){const b=Math.abs(c-l),x=Math.abs(c-u);return{choice:b<=x?1:0,rt:h+o,finalEvidence:c,isContaminated:!1}}else g.type==="continue"?(v=g.residualDrift??0,m=n*(g.noiseMultiplier??1)):(v=0,h-i.stimOffset>(g.collapseDef.delay??0)&&(l-=g.collapseDef.rate*e,u+=g.collapseDef.rate*e))}if(c>=l){f=1,d=!0;break}if(c<=u){f=0,d=!0;break}if(c+=v*e+m*t*Y.normal(0,1),c>=l){f=1,d=!0;break}if(c<=u){f=0,d=!0;break}}let y;return d?y=h+o:(y=i.timeLimit,f=null),{choice:f,rt:y,finalEvidence:c,isContaminated:!1}}function Qw(i,e,t){if(i==null||e.length===0)return null;const s=Array.isArray(t)?t.map(r=>r.toLowerCase()):t?[t.toLowerCase()]:null;if(!s)return e[Math.floor(Y.uniform(0,e.length))];if(i===1){const r=e.filter(n=>s.includes(n.toLowerCase()));if(r.length>0)return r[Math.floor(Y.uniform(0,r.length))]}else{const r=e.filter(n=>!s.includes(n.toLowerCase()));if(r.length>0)return r[Math.floor(Y.uniform(0,r.length))]}return e[Math.floor(Y.uniform(0,e.length))]}var Em={exports:{}},Nl={};/**
10152
+ `)}function cne(i){var s,r;const e=(r=(s=i==null?void 0:i[0])==null?void 0:s.responseData)==null?void 0:r.params;if(!e||typeof e!="object")return{};const t={};for(const[n,a]of Object.entries(e))a&&typeof a=="object"&&(t[n]=a.value??a.defaultValue);return t}const Nw=new Set(["index","trialNumber","start","end","duration","type","name","csv","responseData","metadata"]),dne=new Set(["index","trialNumber","start","end","duration","type","name"]);function pne(i,e,t){var a,o;const s=[],r={};for(const l of e){if(l.index===-1)continue;const u=l.csv,h=u?(Array.isArray(u)?u:[u]).map(c=>({csv:c})):ic[l.type]??[];for(const c of h)c.csv&&(r[c.csv]||(r[c.csv]=[]),r[c.csv].push({item:l,flatten:"flatten"in c?c.flatten:void 0}))}const n={sessionID:i,userAgent:(o=(a=e==null?void 0:e[0])==null?void 0:a.responseData)==null?void 0:o.userAgent,...cne(e),...t};if(r.session){for(const{item:l}of r.session){const u=l.name||l.type;for(const[h,c]of Object.entries(l))Nw.has(h)||(n[`${u}_${h}`]=typeof c=="object"&&c!==null&&!Array.isArray(c)?JSON.stringify(c):c);if(l.responseData&&typeof l.responseData=="object"&&!Array.isArray(l.responseData))for(const[h,c]of Object.entries(l.responseData))n[`${u}_${h}`]=typeof c=="object"&&c!==null&&!Array.isArray(c)?JSON.stringify(c):c}delete r.session}Object.keys(n).length>1&&s.push({filename:`session.${i}.${Date.now()}.csv`,content:rc([n]),encoding:"utf8"});for(const[l,u]of Object.entries(r)){const h=u.flatMap(({item:c,flatten:d})=>{const f={};for(const[v,m]of Object.entries(c))Nw.has(v)?dne.has(v)&&(f[`trial_${v}`]=m):f[v]=typeof m=="object"&&m!==null&&!Array.isArray(m)?JSON.stringify(m):m;return(d?d(c):[c.responseData&&typeof c.responseData=="object"?{...c.responseData}:{}]).map(v=>{const m={...f,...v};for(const g of Object.keys(m)){const b=m[g];typeof b=="object"&&b!==null&&!Array.isArray(b)&&(m[g]=JSON.stringify(b))}return m})});h.length>0&&s.push({filename:`${l}.${i}.${Date.now()}.csv`,content:rc(h),encoding:"utf8"})}return s}function Fw(i){const{sessionID:e,data:t,store:s,generateFiles:r,sessionData:n,uploadRaw:a=!0}=i,o=r?r(e,t,s):[];return a&&o.push({filename:`${e}.raw.json`,content:JSON.stringify(t),encoding:"utf8"}),o.push(...pne(e,t,n)),o}const xm=V.createContext("light"),_n=()=>V.useContext(xm),qw={text:"text-[#f5f5f5]",prose:"prose-invert",proseLink:"prose-a:text-blue-400",buttonBg:"bg-white",buttonText:"text-black",buttonBorder:"border-black",buttonShadow:"shadow-[2px_2px_0px_rgba(0,0,0,1)]",buttonDisabledBg:"bg-gray-700",buttonDisabledText:"text-gray-500",buttonDisabledBorder:"border-gray-600",buttonDisabledShadow:"shadow-[2px_2px_0px_rgba(75,85,99,1)]",error:"text-red-400",focusRing:"focus:ring-blue-400",inputBg:"bg-gray-700",inputBorder:"border-gray-500",inputText:"text-[#f5f5f5]",progressBg:"bg-gray-700",progressStripe1:"#374151",progressStripe2:"#4B5563",dotActive:"#fff",dotInactive:"rgba(255,255,255,0.3)",toastTheme:"dark"},Bw={light:{containerBg:"",text:"text-black",prose:"prose-slate",proseLink:"prose-a:text-blue-600",buttonBg:"bg-white",buttonText:"text-black",buttonBorder:"border-black",buttonShadow:"shadow-[2px_2px_0px_rgba(0,0,0,1)]",buttonDisabledBg:"bg-gray-200",buttonDisabledText:"text-gray-400",buttonDisabledBorder:"border-gray-400",buttonDisabledShadow:"shadow-[2px_2px_0px_rgba(156,163,175,1)]",error:"text-red-500",focusRing:"focus:ring-blue-500",inputBg:"",inputBorder:"border-black",inputText:"",progressBg:"bg-gray-200",progressStripe1:"#E5E7EB",progressStripe2:"#D1D5DB",dotActive:"#000",dotInactive:"rgba(0,0,0,0.2)",toastTheme:"light"},dark:{containerBg:"reactive-dark-bg",...qw},"dark-plain":{containerBg:"reactive-dark-bg-plain",...qw}},fne="reactive-dark-bg",mne="reactive-dark-bg-plain";function Jr(i){return Bw[i]}function nc(i){return typeof i=="number"?i:i.type==="normal"?Y.normal(i.mean,i.sd):Y.uniform(i.min,i.max)}function $w(i){return Math.max(0,nc(i))}function Hw(i){const e=i.dt??1,t=Math.sqrt(e),s=nc(i.startingPoint);if(i.contaminationRate&&Y.uniform(0,1)<i.contaminationRate)return{choice:Y.uniform(0,1)<.5?0:1,rt:Y.uniform(0,i.timeLimit),finalEvidence:s,isContaminated:!0};const r=nc(i.driftRate),n=Math.max(0,nc(i.noiseLevel)),a=i.sensoryDelay!=null?$w(i.sensoryDelay):0,o=i.motorDelay!=null?$w(i.motorDelay):0;let l,u;Array.isArray(i.boundaries)?(u=i.boundaries[0],l=i.boundaries[1]):(l=i.boundaries,u=-i.boundaries);let h=a,c=s,d=!1,f=null;for(;h<i.timeLimit;){h+=e;let v=r,m=n;if(h<=i.stimOffset)i.stimulusCollapse&&h-a>(i.stimulusCollapse.delay??0)&&(l-=i.stimulusCollapse.rate*e,u+=i.stimulusCollapse.rate*e);else{const g=i.postStimStrategy;if(g.type==="snapshot"){const b=Math.abs(c-l),x=Math.abs(c-u);return{choice:b<=x?1:0,rt:h+o,finalEvidence:c,isContaminated:!1}}else g.type==="continue"?(v=g.residualDrift??0,m=n*(g.noiseMultiplier??1)):(v=0,h-i.stimOffset>(g.collapseDef.delay??0)&&(l-=g.collapseDef.rate*e,u+=g.collapseDef.rate*e))}if(c>=l){f=1,d=!0;break}if(c<=u){f=0,d=!0;break}if(c+=v*e+m*t*Y.normal(0,1),c>=l){f=1,d=!0;break}if(c<=u){f=0,d=!0;break}}let y;return d?y=h+o:(y=i.timeLimit,f=null),{choice:f,rt:y,finalEvidence:c,isContaminated:!1}}function Qw(i,e,t){if(i==null||e.length===0)return null;const s=Array.isArray(t)?t.map(r=>r.toLowerCase()):t?[t.toLowerCase()]:null;if(!s)return e[Math.floor(Y.uniform(0,e.length))];if(i===1){const r=e.filter(n=>s.includes(n.toLowerCase()));if(r.length>0)return r[Math.floor(Y.uniform(0,r.length))]}else{const r=e.filter(n=>!s.includes(n.toLowerCase()));if(r.length>0)return r[Math.floor(Y.uniform(0,r.length))]}return e[Math.floor(Y.uniform(0,e.length))]}var Em={exports:{}},Nl={};/**
10153
10153
  * @license React
10154
10154
  * react-jsx-runtime.production.min.js
10155
10155
  *
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-BpIlYaYt.js";
1
+ import { W as e } from "./mod-urua6TFn.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./mod-BpIlYaYt.js";
1
+ import { W as P, b as x, E } from "./mod-urua6TFn.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -130,12 +130,12 @@ function autoBuildCSVs(sessionID: string, data: any[], sessionData?: Record<stri
130
130
  const prefix = item.name || item.type;
131
131
  // Add user-provided metadata (non-builtin top-level keys), namespaced by trial name
132
132
  for (const [key, value] of Object.entries(item)) {
133
- if (!trialBuiltinKeys.has(key)) row[`${prefix}_${key}`] = value;
133
+ if (!trialBuiltinKeys.has(key)) row[`${prefix}_${key}`] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
134
134
  }
135
135
  // Add responseData fields, namespaced by trial name
136
136
  if (item.responseData && typeof item.responseData === 'object' && !Array.isArray(item.responseData)) {
137
137
  for (const [key, value] of Object.entries(item.responseData)) {
138
- row[`${prefix}_${key}`] = value;
138
+ row[`${prefix}_${key}`] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
139
139
  }
140
140
  }
141
141
  }
@@ -159,14 +159,21 @@ function autoBuildCSVs(sessionID: string, data: any[], sessionData?: Record<stri
159
159
  if (trialBuiltinKeys.has(key)) {
160
160
  if (trialInfoKeys.has(key)) base[`trial_${key}`] = value;
161
161
  } else {
162
- base[key] = value;
162
+ base[key] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
163
163
  }
164
164
  }
165
165
  // When no flatten function is registered, spread responseData directly.
166
166
  const flatRows = flatten
167
167
  ? flatten(item)
168
168
  : [item.responseData && typeof item.responseData === 'object' ? { ...item.responseData } : {}];
169
- return flatRows.map((row: any) => ({ ...base, ...row }));
169
+ return flatRows.map((row: any) => {
170
+ const merged = { ...base, ...row };
171
+ for (const k of Object.keys(merged)) {
172
+ const v = merged[k];
173
+ if (typeof v === 'object' && v !== null && !Array.isArray(v)) merged[k] = JSON.stringify(v);
174
+ }
175
+ return merged;
176
+ });
170
177
  });
171
178
  if (rows.length > 0) {
172
179
  files.push({