@adriansteffan/reactive 0.1.1 → 0.1.3
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 +13 -1
- package/README.md +184 -5
- package/dist/{mod-Beb0Bz3s.js → mod-DRCLdWzq.js} +54565 -32232
- package/dist/mod.d.ts +170 -1
- package/dist/reactive.es.js +52 -41
- package/dist/reactive.umd.js +10207 -52
- package/dist/style.css +1 -1
- package/dist/{web-DOXm98lr.js → web-CWqttxrD.js} +1 -1
- package/dist/{web-aMUVS_EB.js → web-N9H86cSP.js} +1 -1
- package/package.json +9 -1
- package/rdk_doc.md +341 -0
- package/src/components/canvasblock.tsx +4 -3
- package/src/components/experimentrunner.tsx +5 -1
- package/src/components/index.ts +4 -0
- package/src/components/mobilefilepermission.tsx +2 -0
- package/src/components/plaininput.tsx +2 -1
- package/src/components/quest.tsx +8 -7
- package/src/components/randomdotkinetogram.tsx +1014 -0
- package/src/components/text.tsx +2 -1
- package/src/components/tutorial.tsx +232 -0
- package/src/components/upload.tsx +2 -1
- package/src/mod.tsx +2 -0
- package/src/utils/array.ts +4 -2
- 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
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
2
3
|
import { default as default_2 } from 'react';
|
|
4
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
3
5
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
4
6
|
import { ReactNode } from 'react';
|
|
7
|
+
import { RefAttributes } from 'react';
|
|
8
|
+
|
|
9
|
+
declare type ApertureShape = 'circle' | 'ellipse' | 'square' | 'rectangle';
|
|
5
10
|
|
|
6
11
|
export declare function arrayFlattener(item: TrialData): any[];
|
|
7
12
|
|
|
@@ -93,6 +98,8 @@ declare interface DeviceInfo {
|
|
|
93
98
|
hasMicrophone: boolean;
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
export declare type DimensionSpec = UniformSpec | NormalSpec | PoissonSpec;
|
|
102
|
+
|
|
96
103
|
export declare function EnterFullscreen({ content, buttonText, next, data, updateStore, delayMs, }: {
|
|
97
104
|
prolificCode?: string;
|
|
98
105
|
content?: default_2.ReactNode;
|
|
@@ -138,6 +145,8 @@ export declare const getPlatform: () => Platform;
|
|
|
138
145
|
|
|
139
146
|
export declare function getSimulation(type: string): ComponentSimulation | undefined;
|
|
140
147
|
|
|
148
|
+
export declare function halton(count: number, specs: DimensionSpec[]): number[] | number[][];
|
|
149
|
+
|
|
141
150
|
declare interface IfBlockItem {
|
|
142
151
|
type: 'IF_BLOCK';
|
|
143
152
|
cond: ConditionalFunction;
|
|
@@ -163,8 +172,18 @@ export declare const MicCheck: ({ next }: {
|
|
|
163
172
|
next: (data: object) => void;
|
|
164
173
|
}) => JSX_2.Element;
|
|
165
174
|
|
|
175
|
+
export declare type NoiseMovement = 'randomTeleport' | 'randomWalk' | 'randomDirection';
|
|
176
|
+
|
|
166
177
|
export declare const noopSimulate: SimulateFunction;
|
|
167
178
|
|
|
179
|
+
export declare let normal: (mu: number, sigma: number) => number;
|
|
180
|
+
|
|
181
|
+
export declare type NormalSpec = {
|
|
182
|
+
distribution: 'normal';
|
|
183
|
+
mean: number;
|
|
184
|
+
sd: number;
|
|
185
|
+
};
|
|
186
|
+
|
|
168
187
|
export declare function now(): number;
|
|
169
188
|
|
|
170
189
|
export declare function orchestrateSimulation(config: RunSimulationConfig, scriptPath: string): Promise<void>;
|
|
@@ -202,6 +221,13 @@ export declare function PlainInput({ content, buttonText, className, next, updat
|
|
|
202
221
|
|
|
203
222
|
export declare type Platform = 'desktop' | 'mobile' | 'web';
|
|
204
223
|
|
|
224
|
+
export declare let poisson: (lambda: number) => number;
|
|
225
|
+
|
|
226
|
+
export declare type PoissonSpec = {
|
|
227
|
+
distribution: 'poisson';
|
|
228
|
+
mean: number;
|
|
229
|
+
};
|
|
230
|
+
|
|
205
231
|
export declare function ProlificEnding({ prolificCode, data, updateStore }: {
|
|
206
232
|
prolificCode?: string;
|
|
207
233
|
} & BaseComponentProps): JSX_2.Element;
|
|
@@ -212,6 +238,96 @@ export declare function Quest({ next, surveyJson, customQuestions, }: {
|
|
|
212
238
|
customQuestions?: ComponentsMap;
|
|
213
239
|
}): JSX_2.Element;
|
|
214
240
|
|
|
241
|
+
export declare const RandomDotKinematogram: (rawProps: RDKProps) => JSX_2.Element;
|
|
242
|
+
|
|
243
|
+
export declare const RDKCanvas: ForwardRefExoticComponent<RDKCanvasProps & RefAttributes<RDKCanvasHandle>>;
|
|
244
|
+
|
|
245
|
+
export declare interface RDKCanvasHandle {
|
|
246
|
+
getStats: () => {
|
|
247
|
+
framesDisplayed: number;
|
|
248
|
+
measuredRefreshRate: number | null;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare interface RDKCanvasProps {
|
|
253
|
+
width: number;
|
|
254
|
+
height: number;
|
|
255
|
+
dotCount?: number;
|
|
256
|
+
dotSetCount?: number;
|
|
257
|
+
direction?: number;
|
|
258
|
+
coherence?: number;
|
|
259
|
+
opposite?: number;
|
|
260
|
+
speed?: number;
|
|
261
|
+
dotLifetime?: number;
|
|
262
|
+
updateRate?: number;
|
|
263
|
+
dotRadius?: number;
|
|
264
|
+
dotCharacter?: string;
|
|
265
|
+
dotColor?: string;
|
|
266
|
+
coherentDotColor?: string;
|
|
267
|
+
backgroundColor?: string;
|
|
268
|
+
apertureShape?: ApertureShape;
|
|
269
|
+
apertureWidth?: number;
|
|
270
|
+
apertureHeight?: number;
|
|
271
|
+
apertureCenterX?: number;
|
|
272
|
+
apertureCenterY?: number;
|
|
273
|
+
reinsertMode?: ReinsertType;
|
|
274
|
+
noiseMovement?: NoiseMovement;
|
|
275
|
+
reassignEveryMs?: number;
|
|
276
|
+
showFixation?: boolean;
|
|
277
|
+
fixationWidth?: number;
|
|
278
|
+
fixationHeight?: number;
|
|
279
|
+
fixationColor?: string;
|
|
280
|
+
fixationThickness?: number;
|
|
281
|
+
showBorder?: boolean;
|
|
282
|
+
borderWidth?: number;
|
|
283
|
+
borderColor?: string;
|
|
284
|
+
/** When true (default), dots are animated and visible. When false, only background (+ fixation if enabled) is shown. */
|
|
285
|
+
active?: boolean;
|
|
286
|
+
/** Seed the refresh-rate estimator (e.g. from a prior calibration). */
|
|
287
|
+
initialRefreshRate?: number;
|
|
288
|
+
style?: CSSProperties;
|
|
289
|
+
className?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export declare interface RDKProps extends BaseComponentProps {
|
|
293
|
+
validKeys?: string[];
|
|
294
|
+
correctResponse?: string | string[];
|
|
295
|
+
duration?: number;
|
|
296
|
+
stimulusDuration?: number;
|
|
297
|
+
responseEndsTrial?: boolean;
|
|
298
|
+
dotCount?: number;
|
|
299
|
+
dotSetCount?: number;
|
|
300
|
+
direction?: number;
|
|
301
|
+
coherence?: number;
|
|
302
|
+
opposite?: number;
|
|
303
|
+
speed?: number;
|
|
304
|
+
dotLifetime?: number;
|
|
305
|
+
updateRate?: number;
|
|
306
|
+
dotRadius?: number;
|
|
307
|
+
dotCharacter?: string;
|
|
308
|
+
dotColor?: string;
|
|
309
|
+
coherentDotColor?: string;
|
|
310
|
+
backgroundColor?: string;
|
|
311
|
+
apertureShape?: ApertureShape;
|
|
312
|
+
apertureWidth?: number;
|
|
313
|
+
apertureHeight?: number;
|
|
314
|
+
apertureCenterX?: number;
|
|
315
|
+
apertureCenterY?: number;
|
|
316
|
+
reinsertMode?: ReinsertType;
|
|
317
|
+
noiseMovement?: NoiseMovement;
|
|
318
|
+
reassignEveryMs?: number;
|
|
319
|
+
showFixation?: boolean;
|
|
320
|
+
fixationTime?: number;
|
|
321
|
+
fixationWidth?: number;
|
|
322
|
+
fixationHeight?: number;
|
|
323
|
+
fixationColor?: string;
|
|
324
|
+
fixationThickness?: number;
|
|
325
|
+
showBorder?: boolean;
|
|
326
|
+
borderWidth?: number;
|
|
327
|
+
borderColor?: string;
|
|
328
|
+
responseHint?: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
215
331
|
/**
|
|
216
332
|
* Registers array methods on the Array prototype.
|
|
217
333
|
* Call this function once to make array methods available globally.
|
|
@@ -240,6 +356,8 @@ export declare function registerFlattener(type: string, csv: string | null, flat
|
|
|
240
356
|
|
|
241
357
|
export declare function registerSimulation(type: string, simulate: SimulateFunction, defaultSimulators: Record<string, any>): void;
|
|
242
358
|
|
|
359
|
+
declare type ReinsertType = 'random' | 'opposite' | 'oppositeSimple' | 'wrap';
|
|
360
|
+
|
|
243
361
|
export declare function RequestFilePermission({ next }: BaseComponentProps): JSX_2.Element | null;
|
|
244
362
|
|
|
245
363
|
export declare function resolveSimulation(content: any, data: TrialResult[], store: Store_2): {
|
|
@@ -252,7 +370,9 @@ export declare interface RunSimulationConfig {
|
|
|
252
370
|
participants: ParticipantState[] | {
|
|
253
371
|
generator: (index: number) => ParticipantState;
|
|
254
372
|
count: number;
|
|
255
|
-
};
|
|
373
|
+
} | (() => ParticipantState[]);
|
|
374
|
+
/** Seed for reproducible simulations. Each participant gets seed + workerIndex. */
|
|
375
|
+
seed?: number;
|
|
256
376
|
backendPort?: number;
|
|
257
377
|
concurrency?: number;
|
|
258
378
|
}
|
|
@@ -262,6 +382,14 @@ export declare interface RunSimulationConfig {
|
|
|
262
382
|
*/
|
|
263
383
|
export declare function sample<T>(array: T[], n?: number): T[];
|
|
264
384
|
|
|
385
|
+
export declare function sampleParticipants<T extends Record<string, DimensionSpec>>(method: SamplingMethod, count: number, specs: T): Array<{
|
|
386
|
+
[K in keyof T]: number;
|
|
387
|
+
}>;
|
|
388
|
+
|
|
389
|
+
export declare type SamplingMethod = 'sobol' | 'halton' | 'random';
|
|
390
|
+
|
|
391
|
+
export declare function seedDistributions(seed: number): void;
|
|
392
|
+
|
|
265
393
|
export declare function setBackendUrl(url: string): void;
|
|
266
394
|
|
|
267
395
|
/**
|
|
@@ -283,6 +411,8 @@ export declare type SimulatorResult = {
|
|
|
283
411
|
duration?: number;
|
|
284
412
|
};
|
|
285
413
|
|
|
414
|
+
export declare function sobol(count: number, specs: DimensionSpec[]): number[] | number[][];
|
|
415
|
+
|
|
286
416
|
export declare interface Store {
|
|
287
417
|
[key: string]: any;
|
|
288
418
|
}
|
|
@@ -321,6 +451,30 @@ export declare interface TrialData {
|
|
|
321
451
|
|
|
322
452
|
declare type TrialResult = ComponentResultData | CanvasResultData;
|
|
323
453
|
|
|
454
|
+
export declare const Tutorial: ({ next, slides, fadeDuration, finishText, containerClass, nextKey, backKey, theme, }: TutorialProps) => JSX_2.Element;
|
|
455
|
+
|
|
456
|
+
export declare interface TutorialProps extends BaseComponentProps {
|
|
457
|
+
slides: ReactNode[];
|
|
458
|
+
/** Fade duration in seconds (default: 0.3) */
|
|
459
|
+
fadeDuration?: number;
|
|
460
|
+
finishText?: string;
|
|
461
|
+
containerClass?: string;
|
|
462
|
+
/** Key to go forward (default: 'ArrowRight', set to false to disable) */
|
|
463
|
+
nextKey?: string | false;
|
|
464
|
+
/** Key to go back (default: 'ArrowLeft', set to false to disable) */
|
|
465
|
+
backKey?: string | false;
|
|
466
|
+
/** Color mode for dot indicators (default: 'light') */
|
|
467
|
+
theme?: 'light' | 'dark';
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export declare let uniform: (min: number, max: number) => number;
|
|
471
|
+
|
|
472
|
+
export declare type UniformSpec = {
|
|
473
|
+
distribution: 'uniform';
|
|
474
|
+
min: number;
|
|
475
|
+
max: number;
|
|
476
|
+
};
|
|
477
|
+
|
|
324
478
|
declare interface UpdateStoreItem {
|
|
325
479
|
type: 'UPDATE_STORE';
|
|
326
480
|
fun: StoreUpdateFunction;
|
|
@@ -335,6 +489,21 @@ export declare function Upload({ data, next, store, sessionID, generateFiles, se
|
|
|
335
489
|
androidFolderName?: string;
|
|
336
490
|
}): JSX_2.Element;
|
|
337
491
|
|
|
492
|
+
/**
|
|
493
|
+
* Hook for interactive slide components.
|
|
494
|
+
* Call with `{ locked: true }` to start with the next button disabled.
|
|
495
|
+
* Then call `unlock()` when the interaction is complete.
|
|
496
|
+
* Call `unlock({ autoAdvanceMs: 1000 })` to auto-advance after a delay.
|
|
497
|
+
*/
|
|
498
|
+
export declare const useTutorialSlide: ({ locked }?: {
|
|
499
|
+
locked?: boolean | undefined;
|
|
500
|
+
}) => {
|
|
501
|
+
setData: (data: Record<string, unknown>) => void;
|
|
502
|
+
unlock: ({ autoAdvanceMs }?: {
|
|
503
|
+
autoAdvanceMs?: number;
|
|
504
|
+
}) => void;
|
|
505
|
+
};
|
|
506
|
+
|
|
338
507
|
declare interface WhileBlockItem {
|
|
339
508
|
type: 'WHILE_BLOCK';
|
|
340
509
|
cond: ConditionalFunction;
|
package/dist/reactive.es.js
CHANGED
|
@@ -1,53 +1,64 @@
|
|
|
1
|
-
import { H as e, C as t, a as
|
|
1
|
+
import { H as e, C as t, a as i, c as n, d as r, 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 x, i as C, j as T, F as k, T as E, k as F, l as S, U as f, X as h, m as v, n as B, o as D, p as R, q as y, r as I, s as U, t as b, u as w, v as K, w as q, x as A, y as M, 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 na, a7 as ra, a8 as oa, a9 as la } from "./mod-DRCLdWzq.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Bounce,
|
|
4
4
|
t as CanvasBlock,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
i as CheckDevice,
|
|
6
|
+
n as EnterFullscreen,
|
|
7
|
+
r as ExitFullscreen,
|
|
8
8
|
o as ExperimentProvider,
|
|
9
9
|
l as ExperimentRunner,
|
|
10
10
|
m as Flip,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
u as Icons,
|
|
12
|
+
c as MicCheck,
|
|
13
13
|
p as Param,
|
|
14
14
|
P as PlainInput,
|
|
15
15
|
g as ProlificEnding,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
d as Quest,
|
|
17
|
+
x as RDKCanvas,
|
|
18
|
+
C as RandomDotKinematogram,
|
|
19
|
+
T as RequestFilePermission,
|
|
18
20
|
k as Slide,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
y as
|
|
29
|
-
I as
|
|
30
|
-
U as
|
|
21
|
+
E as Text,
|
|
22
|
+
F as ToastContainer,
|
|
23
|
+
S as Tutorial,
|
|
24
|
+
f as Upload,
|
|
25
|
+
h as Zoom,
|
|
26
|
+
v as arrayFlattener,
|
|
27
|
+
B as canvasCountdown,
|
|
28
|
+
D as chunk,
|
|
29
|
+
R as collapseToast,
|
|
30
|
+
y as cssTransition,
|
|
31
|
+
I as getBackendUrl,
|
|
32
|
+
U as getInitialParticipant,
|
|
33
|
+
b as getParam,
|
|
31
34
|
w as getPlatform,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
K as getSimulation,
|
|
36
|
+
q as halton,
|
|
37
|
+
A as isDesktop,
|
|
38
|
+
M as isFullscreen,
|
|
39
|
+
Q as noopSimulate,
|
|
40
|
+
Z as normal,
|
|
41
|
+
j as now,
|
|
42
|
+
z as orchestrateSimulation,
|
|
43
|
+
G as pipe,
|
|
44
|
+
H as poisson,
|
|
45
|
+
J as registerArrayExtensions,
|
|
46
|
+
L as registerComponentParams,
|
|
47
|
+
N as registerExperimentParams,
|
|
48
|
+
O as registerFlattener,
|
|
49
|
+
V as registerSimulation,
|
|
50
|
+
X as resolveSimulation,
|
|
51
|
+
Y as sample,
|
|
52
|
+
_ as sampleParticipants,
|
|
53
|
+
$ as seedDistributions,
|
|
54
|
+
W as setBackendUrl,
|
|
55
|
+
aa as shuffle,
|
|
56
|
+
sa as simulateParticipant,
|
|
57
|
+
ea as sobol,
|
|
58
|
+
ta as subsetExperimentByParam,
|
|
59
|
+
ia as toast,
|
|
60
|
+
na as uniform,
|
|
61
|
+
ra as useToast,
|
|
62
|
+
oa as useToastContainer,
|
|
63
|
+
la as useTutorialSlide
|
|
53
64
|
};
|