@adriansteffan/reactive 0.1.2 → 0.1.4
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/.claude/settings.local.json +24 -1
- package/README.md +219 -5
- package/dist/{mod-Bb_FAy0j.js → mod-DHUjIRfF.js} +31267 -14835
- package/dist/mod.d.ts +104 -1
- package/dist/reactive.es.js +50 -41
- package/dist/reactive.umd.js +10202 -55
- package/dist/style.css +1 -1
- package/dist/{web-DmsP-pmx.js → web-BGLPXsYu.js} +1 -1
- package/dist/{web-BfWhpr9p.js → web-DGGPscOK.js} +1 -1
- package/package.json +8 -1
- package/src/components/canvasblock.tsx +4 -3
- package/src/components/plaininput.tsx +2 -1
- package/src/components/quest.tsx +8 -7
- package/src/components/randomdotkinetogram.tsx +36 -25
- package/src/components/text.tsx +2 -1
- package/src/components/upload.tsx +2 -1
- package/src/mod.tsx +4 -0
- package/src/utils/array.ts +4 -2
- package/src/utils/ddm.test.ts +233 -0
- package/src/utils/ddm.ts +230 -0
- package/src/utils/distributions.test.ts +209 -0
- package/src/utils/distributions.ts +191 -0
- package/src/utils/simulation.ts +9 -4
- package/template/simulate.ts +24 -4
- package/template/src/Experiment.tsx +7 -9
package/dist/mod.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ declare type BaseTrialData = {
|
|
|
25
25
|
duration: number;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
export declare type BoundaryDef = number | [number, number];
|
|
29
|
+
|
|
28
30
|
export declare function CanvasBlock({ next, updateStore, timeline, width, height, store, styleCanvas, initCanvas, }: CanvasBlockProps): JSX_2.Element;
|
|
29
31
|
|
|
30
32
|
declare type CanvasBlockProps = {
|
|
@@ -57,6 +59,16 @@ export declare function CheckDevice({ check, content, data, store, updateStore,
|
|
|
57
59
|
*/
|
|
58
60
|
export declare function chunk<T>(array: T[], n: number): T[][];
|
|
59
61
|
|
|
62
|
+
export declare type CollapseDef = {
|
|
63
|
+
rate: number;
|
|
64
|
+
delay?: number;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export declare type CollapseStrategy = {
|
|
68
|
+
type: 'collapse';
|
|
69
|
+
collapseDef: CollapseDef;
|
|
70
|
+
};
|
|
71
|
+
|
|
60
72
|
declare type ComponentResultData = BaseTrialData & {
|
|
61
73
|
type: string;
|
|
62
74
|
name: string;
|
|
@@ -81,8 +93,36 @@ declare type ComponentsMap_2 = {
|
|
|
81
93
|
|
|
82
94
|
declare type ConditionalFunction = (data?: TrialResult[], store?: Store_2) => boolean;
|
|
83
95
|
|
|
96
|
+
export declare type ContinueStrategy = {
|
|
97
|
+
type: 'continue';
|
|
98
|
+
residualDrift?: number;
|
|
99
|
+
noiseMultiplier?: number;
|
|
100
|
+
};
|
|
101
|
+
|
|
84
102
|
declare type ControlFlowItem = MarkerItem | IfGotoItem | UpdateStoreItem | IfBlockItem | WhileBlockItem;
|
|
85
103
|
|
|
104
|
+
export declare interface DDMTrialParams {
|
|
105
|
+
driftRate: ParameterDef;
|
|
106
|
+
boundaries: BoundaryDef;
|
|
107
|
+
startingPoint: ParameterDef;
|
|
108
|
+
noiseLevel: ParameterDef;
|
|
109
|
+
sensoryDelay?: ParameterDef;
|
|
110
|
+
motorDelay?: ParameterDef;
|
|
111
|
+
timeLimit: number;
|
|
112
|
+
stimOffset: number;
|
|
113
|
+
dt?: number;
|
|
114
|
+
contaminationRate?: number;
|
|
115
|
+
stimulusCollapse?: CollapseDef;
|
|
116
|
+
postStimStrategy: PostStimStrategyDef;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare interface DDMTrialResult {
|
|
120
|
+
choice: 0 | 1 | null;
|
|
121
|
+
rt: number;
|
|
122
|
+
finalEvidence: number;
|
|
123
|
+
isContaminated: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
86
126
|
declare interface DeviceInfo {
|
|
87
127
|
windowWidth: number;
|
|
88
128
|
windowHeight: number;
|
|
@@ -98,6 +138,8 @@ declare interface DeviceInfo {
|
|
|
98
138
|
hasMicrophone: boolean;
|
|
99
139
|
}
|
|
100
140
|
|
|
141
|
+
export declare type DimensionSpec = UniformSpec | NormalSpec | PoissonSpec;
|
|
142
|
+
|
|
101
143
|
export declare function EnterFullscreen({ content, buttonText, next, data, updateStore, delayMs, }: {
|
|
102
144
|
prolificCode?: string;
|
|
103
145
|
content?: default_2.ReactNode;
|
|
@@ -143,6 +185,8 @@ export declare const getPlatform: () => Platform;
|
|
|
143
185
|
|
|
144
186
|
export declare function getSimulation(type: string): ComponentSimulation | undefined;
|
|
145
187
|
|
|
188
|
+
export declare function halton(count: number, specs: DimensionSpec[]): number[] | number[][];
|
|
189
|
+
|
|
146
190
|
declare interface IfBlockItem {
|
|
147
191
|
type: 'IF_BLOCK';
|
|
148
192
|
cond: ConditionalFunction;
|
|
@@ -159,6 +203,8 @@ export declare function isDesktop(): boolean;
|
|
|
159
203
|
|
|
160
204
|
export declare function isFullscreen(): boolean;
|
|
161
205
|
|
|
206
|
+
export declare function mapDDMChoice(choice: 0 | 1 | null, validKeys: string[], correctResponse?: string | string[]): string | null;
|
|
207
|
+
|
|
162
208
|
declare interface MarkerItem {
|
|
163
209
|
type: 'MARKER';
|
|
164
210
|
id: string;
|
|
@@ -172,6 +218,20 @@ export declare type NoiseMovement = 'randomTeleport' | 'randomWalk' | 'randomDir
|
|
|
172
218
|
|
|
173
219
|
export declare const noopSimulate: SimulateFunction;
|
|
174
220
|
|
|
221
|
+
export declare let normal: (mu: number, sigma: number) => number;
|
|
222
|
+
|
|
223
|
+
export declare type NormalDist = {
|
|
224
|
+
type: 'normal';
|
|
225
|
+
mean: number;
|
|
226
|
+
sd: number;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export declare type NormalSpec = {
|
|
230
|
+
distribution: 'normal';
|
|
231
|
+
mean: number;
|
|
232
|
+
sd: number;
|
|
233
|
+
};
|
|
234
|
+
|
|
175
235
|
export declare function now(): number;
|
|
176
236
|
|
|
177
237
|
export declare function orchestrateSimulation(config: RunSimulationConfig, scriptPath: string): Promise<void>;
|
|
@@ -184,6 +244,8 @@ export declare class Param {
|
|
|
184
244
|
}[];
|
|
185
245
|
}
|
|
186
246
|
|
|
247
|
+
export declare type ParameterDef = number | NormalDist | UniformDist;
|
|
248
|
+
|
|
187
249
|
declare type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
|
|
188
250
|
|
|
189
251
|
declare type ParamValue<T extends ParamType> = T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'array' | 'json' ? any : string;
|
|
@@ -209,6 +271,15 @@ export declare function PlainInput({ content, buttonText, className, next, updat
|
|
|
209
271
|
|
|
210
272
|
export declare type Platform = 'desktop' | 'mobile' | 'web';
|
|
211
273
|
|
|
274
|
+
export declare let poisson: (lambda: number) => number;
|
|
275
|
+
|
|
276
|
+
export declare type PoissonSpec = {
|
|
277
|
+
distribution: 'poisson';
|
|
278
|
+
mean: number;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export declare type PostStimStrategyDef = ContinueStrategy | CollapseStrategy | SnapshotStrategy;
|
|
282
|
+
|
|
212
283
|
export declare function ProlificEnding({ prolificCode, data, updateStore }: {
|
|
213
284
|
prolificCode?: string;
|
|
214
285
|
} & BaseComponentProps): JSX_2.Element;
|
|
@@ -351,7 +422,9 @@ export declare interface RunSimulationConfig {
|
|
|
351
422
|
participants: ParticipantState[] | {
|
|
352
423
|
generator: (index: number) => ParticipantState;
|
|
353
424
|
count: number;
|
|
354
|
-
};
|
|
425
|
+
} | (() => ParticipantState[]);
|
|
426
|
+
/** Seed for reproducible simulations. Each participant gets seed + workerIndex. */
|
|
427
|
+
seed?: number;
|
|
355
428
|
backendPort?: number;
|
|
356
429
|
concurrency?: number;
|
|
357
430
|
}
|
|
@@ -361,6 +434,14 @@ export declare interface RunSimulationConfig {
|
|
|
361
434
|
*/
|
|
362
435
|
export declare function sample<T>(array: T[], n?: number): T[];
|
|
363
436
|
|
|
437
|
+
export declare function sampleParticipants<T extends Record<string, DimensionSpec>>(method: SamplingMethod, count: number, specs: T): Array<{
|
|
438
|
+
[K in keyof T]: number;
|
|
439
|
+
}>;
|
|
440
|
+
|
|
441
|
+
export declare type SamplingMethod = 'sobol' | 'halton' | 'random';
|
|
442
|
+
|
|
443
|
+
export declare function seedDistributions(seed: number): void;
|
|
444
|
+
|
|
364
445
|
export declare function setBackendUrl(url: string): void;
|
|
365
446
|
|
|
366
447
|
/**
|
|
@@ -368,6 +449,8 @@ export declare function setBackendUrl(url: string): void;
|
|
|
368
449
|
*/
|
|
369
450
|
export declare function shuffle<T>(array: T[]): T[];
|
|
370
451
|
|
|
452
|
+
export declare function simulateDDMTrial(params: DDMTrialParams): DDMTrialResult;
|
|
453
|
+
|
|
371
454
|
export declare type SimulateFunction = (trialProps: Record<string, any>, experimentState: {
|
|
372
455
|
data: TrialResult[];
|
|
373
456
|
store: Store_2;
|
|
@@ -382,6 +465,12 @@ export declare type SimulatorResult = {
|
|
|
382
465
|
duration?: number;
|
|
383
466
|
};
|
|
384
467
|
|
|
468
|
+
export declare type SnapshotStrategy = {
|
|
469
|
+
type: 'snapshot';
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
export declare function sobol(count: number, specs: DimensionSpec[]): number[] | number[][];
|
|
473
|
+
|
|
385
474
|
export declare interface Store {
|
|
386
475
|
[key: string]: any;
|
|
387
476
|
}
|
|
@@ -436,6 +525,20 @@ export declare interface TutorialProps extends BaseComponentProps {
|
|
|
436
525
|
theme?: 'light' | 'dark';
|
|
437
526
|
}
|
|
438
527
|
|
|
528
|
+
export declare let uniform: (min: number, max: number) => number;
|
|
529
|
+
|
|
530
|
+
export declare type UniformDist = {
|
|
531
|
+
type: 'uniform';
|
|
532
|
+
min: number;
|
|
533
|
+
max: number;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
export declare type UniformSpec = {
|
|
537
|
+
distribution: 'uniform';
|
|
538
|
+
min: number;
|
|
539
|
+
max: number;
|
|
540
|
+
};
|
|
541
|
+
|
|
439
542
|
declare interface UpdateStoreItem {
|
|
440
543
|
type: 'UPDATE_STORE';
|
|
441
544
|
fun: StoreUpdateFunction;
|
package/dist/reactive.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g, h as
|
|
1
|
+
import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g as P, h as g, Q as d, R as C, i as D, j as T, F as x, T as h, k, l as E, U as F, X as S, m as f, n as v, o as B, p as R, q as b, r as y, s as I, t as M, u as U, v as w, w as K, x as q, y as A, A as Q, B as Z, D as j, G as z, I as G, J as H, K as J, L, N, O, S as V, V as X, Z 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 } from "./mod-DHUjIRfF.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Bounce,
|
|
4
4
|
t as CanvasBlock,
|
|
@@ -11,47 +11,56 @@ export {
|
|
|
11
11
|
u as Icons,
|
|
12
12
|
c as MicCheck,
|
|
13
13
|
p as Param,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
P as PlainInput,
|
|
15
|
+
g as ProlificEnding,
|
|
16
16
|
d as Quest,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
C as RDKCanvas,
|
|
18
|
+
D as RandomDotKinematogram,
|
|
19
19
|
T as RequestFilePermission,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
x as Slide,
|
|
21
|
+
h as Text,
|
|
22
|
+
k as ToastContainer,
|
|
23
|
+
E as Tutorial,
|
|
24
|
+
F as Upload,
|
|
25
|
+
S as Zoom,
|
|
26
|
+
f as arrayFlattener,
|
|
27
|
+
v as canvasCountdown,
|
|
28
|
+
B as chunk,
|
|
29
29
|
R as collapseToast,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
j as
|
|
42
|
-
z as
|
|
43
|
-
G as
|
|
44
|
-
H as
|
|
45
|
-
J as
|
|
46
|
-
L as
|
|
47
|
-
N as
|
|
48
|
-
O as
|
|
49
|
-
V as
|
|
50
|
-
X as
|
|
51
|
-
Y as
|
|
52
|
-
_ as
|
|
53
|
-
$ as
|
|
54
|
-
W as
|
|
55
|
-
aa as
|
|
56
|
-
sa as
|
|
30
|
+
b as cssTransition,
|
|
31
|
+
y as getBackendUrl,
|
|
32
|
+
I as getInitialParticipant,
|
|
33
|
+
M as getParam,
|
|
34
|
+
U as getPlatform,
|
|
35
|
+
w as getSimulation,
|
|
36
|
+
K as halton,
|
|
37
|
+
q as isDesktop,
|
|
38
|
+
A as isFullscreen,
|
|
39
|
+
Q as mapDDMChoice,
|
|
40
|
+
Z as noopSimulate,
|
|
41
|
+
j as normal,
|
|
42
|
+
z as now,
|
|
43
|
+
G as orchestrateSimulation,
|
|
44
|
+
H as pipe,
|
|
45
|
+
J as poisson,
|
|
46
|
+
L as registerArrayExtensions,
|
|
47
|
+
N as registerComponentParams,
|
|
48
|
+
O as registerExperimentParams,
|
|
49
|
+
V as registerFlattener,
|
|
50
|
+
X as registerSimulation,
|
|
51
|
+
Y as resolveSimulation,
|
|
52
|
+
_ as sample,
|
|
53
|
+
$ as sampleParticipants,
|
|
54
|
+
W as seedDistributions,
|
|
55
|
+
aa as setBackendUrl,
|
|
56
|
+
sa as shuffle,
|
|
57
|
+
ea as simulateDDMTrial,
|
|
58
|
+
ta as simulateParticipant,
|
|
59
|
+
ia as sobol,
|
|
60
|
+
ra as subsetExperimentByParam,
|
|
61
|
+
na as toast,
|
|
62
|
+
oa as uniform,
|
|
63
|
+
la as useToast,
|
|
64
|
+
ma as useToastContainer,
|
|
65
|
+
ua as useTutorialSlide
|
|
57
66
|
};
|