@adriansteffan/reactive 0.0.43 → 0.1.0
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 +14 -1
- package/README.md +232 -3
- package/dist/{mod-D6W3wq3h.js → mod-D9lwPIrH.js} +6739 -6389
- package/dist/mod.d.ts +70 -22
- package/dist/reactive.es.js +46 -36
- package/dist/reactive.umd.js +40 -38
- package/dist/style.css +1 -1
- package/dist/{web-B1hJOwit.js → web-DUIQX1PV.js} +1 -1
- package/dist/{web-BYSmfdtR.js → web-DXP3LAJm.js} +1 -1
- package/package.json +1 -1
- package/src/components/canvasblock.tsx +125 -74
- package/src/components/checkdevice.tsx +18 -0
- package/src/components/enterfullscreen.tsx +7 -3
- package/src/components/exitfullscreen.tsx +6 -1
- package/src/components/experimentprovider.tsx +7 -2
- package/src/components/experimentrunner.tsx +85 -58
- package/src/components/microphonecheck.tsx +6 -1
- package/src/components/mobilefilepermission.tsx +3 -0
- package/src/components/plaininput.tsx +20 -0
- package/src/components/prolificending.tsx +5 -0
- package/src/components/quest.tsx +60 -0
- package/src/components/storeui.tsx +18 -11
- package/src/components/text.tsx +14 -0
- package/src/components/upload.tsx +69 -286
- package/src/index.css +0 -20
- package/src/mod.tsx +2 -0
- package/src/utils/bytecode.ts +61 -9
- package/src/utils/common.ts +4 -1
- package/src/utils/simulation.ts +269 -0
- package/src/utils/upload.ts +201 -0
- package/template/README.md +59 -0
- package/template/backend/package-lock.json +280 -156
- package/template/backend/src/backend.ts +1 -0
- package/template/package-lock.json +1693 -771
- package/template/package.json +2 -0
- package/template/simulate.ts +15 -0
- package/template/src/Experiment.tsx +62 -5
- package/template/src/main.tsx +1 -1
- package/template/tsconfig.json +2 -3
- package/tsconfig.json +1 -0
- package/vite.config.ts +1 -1
package/dist/mod.d.ts
CHANGED
|
@@ -53,10 +53,17 @@ export declare function chunk<T>(array: T[], n: number): T[][];
|
|
|
53
53
|
declare type ComponentResultData = BaseTrialData & {
|
|
54
54
|
type: string;
|
|
55
55
|
name: string;
|
|
56
|
+
/** Per-trial override for which CSV file(s) this trial's data goes into. When set on a timeline item, overrides the component type's default from the flattener registry. */
|
|
57
|
+
csv?: string | string[];
|
|
56
58
|
responseData?: any;
|
|
57
59
|
metadata?: Record<string, any>;
|
|
58
60
|
};
|
|
59
61
|
|
|
62
|
+
declare interface ComponentSimulation {
|
|
63
|
+
simulate: SimulateFunction;
|
|
64
|
+
defaultSimulators: Record<string, any>;
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
declare type ComponentsMap = {
|
|
61
68
|
[key: string]: ComponentType<any>;
|
|
62
69
|
};
|
|
@@ -65,16 +72,10 @@ declare type ComponentsMap_2 = {
|
|
|
65
72
|
[key: string]: ComponentType<any>;
|
|
66
73
|
};
|
|
67
74
|
|
|
68
|
-
declare type ConditionalFunction = (data?:
|
|
75
|
+
declare type ConditionalFunction = (data?: TrialResult[], store?: Store_2) => boolean;
|
|
69
76
|
|
|
70
77
|
declare type ControlFlowItem = MarkerItem | IfGotoItem | UpdateStoreItem | IfBlockItem | WhileBlockItem;
|
|
71
78
|
|
|
72
|
-
declare type CSVBuilder = {
|
|
73
|
-
filename?: string;
|
|
74
|
-
trials?: string[];
|
|
75
|
-
fun?: (row: Record<string, any>) => Record<string, any>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
79
|
declare interface DeviceInfo {
|
|
79
80
|
windowWidth: number;
|
|
80
81
|
windowHeight: number;
|
|
@@ -105,16 +106,18 @@ export declare interface ExperimentConfig {
|
|
|
105
106
|
showProgressBar: boolean;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
export declare function ExperimentProvider({ children, disableSettings }: {
|
|
109
|
+
export declare function ExperimentProvider({ children, disableSettings, disableHybridSimulation }: {
|
|
109
110
|
children: ReactNode;
|
|
110
111
|
disableSettings?: boolean;
|
|
112
|
+
disableHybridSimulation?: boolean;
|
|
111
113
|
}): JSX_2.Element;
|
|
112
114
|
|
|
113
|
-
export declare function ExperimentRunner({ timeline, config, components, questions, }: {
|
|
115
|
+
export declare function ExperimentRunner({ timeline, config, components, questions, hybridParticipant, }: {
|
|
114
116
|
timeline: TimelineItem[];
|
|
115
117
|
config?: ExperimentConfig;
|
|
116
118
|
components?: ComponentsMap_2;
|
|
117
119
|
questions?: ComponentsMap_2;
|
|
120
|
+
hybridParticipant?: ParticipantState;
|
|
118
121
|
}): JSX_2.Element;
|
|
119
122
|
|
|
120
123
|
export declare interface FileUpload {
|
|
@@ -123,10 +126,16 @@ export declare interface FileUpload {
|
|
|
123
126
|
encoding?: 'base64' | 'utf8';
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
export declare function
|
|
129
|
+
export declare function getBackendUrl(): string;
|
|
130
|
+
|
|
131
|
+
export declare function getInitialParticipant(): ParticipantState | undefined;
|
|
132
|
+
|
|
133
|
+
export declare function getParam<T extends ParamType>(name: string, defaultValue: ParamValue<T>, type?: T, description?: string, uiDefault?: string): ParamValue<T>;
|
|
127
134
|
|
|
128
135
|
export declare const getPlatform: () => Platform;
|
|
129
136
|
|
|
137
|
+
export declare function getSimulation(type: string): ComponentSimulation | undefined;
|
|
138
|
+
|
|
130
139
|
declare interface IfBlockItem {
|
|
131
140
|
type: 'IF_BLOCK';
|
|
132
141
|
cond: ConditionalFunction;
|
|
@@ -152,8 +161,12 @@ export declare const MicCheck: ({ next }: {
|
|
|
152
161
|
next: (data: object) => void;
|
|
153
162
|
}) => JSX_2.Element;
|
|
154
163
|
|
|
164
|
+
export declare const noopSimulate: SimulateFunction;
|
|
165
|
+
|
|
155
166
|
export declare function now(): number;
|
|
156
167
|
|
|
168
|
+
export declare function orchestrateSimulation(config: RunSimulationConfig, scriptPath: string): Promise<void>;
|
|
169
|
+
|
|
157
170
|
export declare class Param {
|
|
158
171
|
static getRegistry(): any[];
|
|
159
172
|
static getTimelineRepresentation(): {
|
|
@@ -166,6 +179,8 @@ declare type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
|
|
|
166
179
|
|
|
167
180
|
declare type ParamValue<T extends ParamType> = T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'array' | 'json' ? any : string;
|
|
168
181
|
|
|
182
|
+
export declare type ParticipantState = Record<string, any>;
|
|
183
|
+
|
|
169
184
|
/**
|
|
170
185
|
* Applies a function to an array
|
|
171
186
|
*/
|
|
@@ -195,8 +210,6 @@ export declare function Quest({ next, surveyJson, customQuestions, }: {
|
|
|
195
210
|
customQuestions?: ComponentsMap;
|
|
196
211
|
}): JSX_2.Element;
|
|
197
212
|
|
|
198
|
-
declare type RefinedTrialData = ComponentResultData | CanvasResultData;
|
|
199
|
-
|
|
200
213
|
/**
|
|
201
214
|
* Registers array methods on the Array prototype.
|
|
202
215
|
* Call this function once to make array methods available globally.
|
|
@@ -221,25 +234,60 @@ export declare function registerComponentParams(type: string, params: {
|
|
|
221
234
|
|
|
222
235
|
export declare function registerExperimentParams(experiment: any[]): void;
|
|
223
236
|
|
|
237
|
+
export declare function registerFlattener(type: string, csv: string | null, flatten?: (item: TrialData) => any[]): void;
|
|
238
|
+
|
|
239
|
+
export declare function registerSimulation(type: string, simulate: SimulateFunction, defaultSimulators: Record<string, any>): void;
|
|
240
|
+
|
|
224
241
|
export declare function RequestFilePermission({ next }: BaseComponentProps): JSX_2.Element | null;
|
|
225
242
|
|
|
243
|
+
export declare function resolveSimulation(content: any, data: TrialResult[], store: Store_2): {
|
|
244
|
+
trialProps: any;
|
|
245
|
+
simulateFn: any;
|
|
246
|
+
simulators: any;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export declare interface RunSimulationConfig {
|
|
250
|
+
participants: ParticipantState[] | {
|
|
251
|
+
generator: (index: number) => ParticipantState;
|
|
252
|
+
count: number;
|
|
253
|
+
};
|
|
254
|
+
backendPort?: number;
|
|
255
|
+
concurrency?: number;
|
|
256
|
+
}
|
|
257
|
+
|
|
226
258
|
/**
|
|
227
259
|
* Returns random elements from an array
|
|
228
260
|
*/
|
|
229
261
|
export declare function sample<T>(array: T[], n?: number): T[];
|
|
230
262
|
|
|
263
|
+
export declare function setBackendUrl(url: string): void;
|
|
264
|
+
|
|
231
265
|
/**
|
|
232
266
|
* Shuffles array elements using Fisher-Yates algorithm
|
|
233
267
|
*/
|
|
234
268
|
export declare function shuffle<T>(array: T[]): T[];
|
|
235
269
|
|
|
270
|
+
export declare type SimulateFunction = (trialProps: Record<string, any>, experimentState: {
|
|
271
|
+
data: TrialResult[];
|
|
272
|
+
store: Store_2;
|
|
273
|
+
}, simulators: Record<string, any>, participant: ParticipantState) => SimulatorResult | Promise<SimulatorResult>;
|
|
274
|
+
|
|
275
|
+
export declare function simulateParticipant(timeline: TimelineItem[], participant: ParticipantState): Promise<TrialResult[]>;
|
|
276
|
+
|
|
277
|
+
export declare type SimulatorResult = {
|
|
278
|
+
responseData: any;
|
|
279
|
+
participantState: ParticipantState;
|
|
280
|
+
storeUpdates?: Record<string, any>;
|
|
281
|
+
duration?: number;
|
|
282
|
+
};
|
|
283
|
+
|
|
236
284
|
export declare interface Store {
|
|
237
285
|
[key: string]: any;
|
|
238
286
|
}
|
|
239
287
|
|
|
240
288
|
declare type Store_2 = Record<string, any>;
|
|
241
289
|
|
|
242
|
-
declare type StoreUpdateFunction = (data?:
|
|
290
|
+
declare type StoreUpdateFunction = (data?: TrialResult[], store?: Store_2) => Record<string, any>;
|
|
243
291
|
|
|
244
292
|
export declare function subsetExperimentByParam(experiment: any[]): any[];
|
|
245
293
|
|
|
@@ -261,27 +309,27 @@ export declare interface TrialData {
|
|
|
261
309
|
trialNumber: number;
|
|
262
310
|
type: string;
|
|
263
311
|
name: string;
|
|
312
|
+
/** Populated from the timeline item's csv field. Overrides the component type's default CSV target from the flattener registry. */
|
|
313
|
+
csv?: string | string[];
|
|
264
314
|
responseData: any;
|
|
265
315
|
start: number;
|
|
266
316
|
end: number;
|
|
267
317
|
duration: number;
|
|
268
318
|
}
|
|
269
319
|
|
|
320
|
+
declare type TrialResult = ComponentResultData | CanvasResultData;
|
|
321
|
+
|
|
270
322
|
declare interface UpdateStoreItem {
|
|
271
323
|
type: 'UPDATE_STORE';
|
|
272
324
|
fun: StoreUpdateFunction;
|
|
273
325
|
}
|
|
274
326
|
|
|
275
|
-
export declare function Upload({ data, next, store, sessionID, generateFiles,
|
|
327
|
+
export declare function Upload({ data, next, store, sessionID, generateFiles, sessionData, uploadRaw, autoUpload, androidFolderName, }: BaseComponentProps & {
|
|
276
328
|
sessionID?: string | null;
|
|
277
|
-
generateFiles
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
builders: CSVBuilder[];
|
|
282
|
-
};
|
|
283
|
-
uploadRaw: boolean;
|
|
284
|
-
autoUpload: boolean;
|
|
329
|
+
generateFiles?: (sessionID: string, data: TrialData[], store?: Store) => FileUpload[];
|
|
330
|
+
sessionData?: Record<string, any>;
|
|
331
|
+
uploadRaw?: boolean;
|
|
332
|
+
autoUpload?: boolean;
|
|
285
333
|
androidFolderName?: string;
|
|
286
334
|
}): JSX_2.Element;
|
|
287
335
|
|
package/dist/reactive.es.js
CHANGED
|
@@ -1,42 +1,52 @@
|
|
|
1
|
-
import { H as e, C 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 c, M as u, P as p, g as P, h as g, Q as x, R as d, F as k, T as C, i as E, U as F, X as S, j as T, k as f, l as h, m as v, n as B, o as I, p as U, q as w, r as y, s as D, t as R, u as q, v as A, w as M, x as Q, y as Z, A as b, B as j, D as z, G, I as H, J, K, L, N, O, S as V, V as X, Z as Y } from "./mod-D9lwPIrH.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Bounce,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
t as CanvasBlock,
|
|
5
|
+
i as CheckDevice,
|
|
6
|
+
n as EnterFullscreen,
|
|
7
|
+
r as ExitFullscreen,
|
|
8
8
|
o as ExperimentProvider,
|
|
9
9
|
l as ExperimentRunner,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
m as Flip,
|
|
11
|
+
c as Icons,
|
|
12
|
+
u as MicCheck,
|
|
13
|
+
p as Param,
|
|
14
14
|
P as PlainInput,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
g as ProlificEnding,
|
|
16
|
+
x as Quest,
|
|
17
|
+
d as RequestFilePermission,
|
|
18
|
+
k as Slide,
|
|
19
|
+
C as Text,
|
|
20
|
+
E as ToastContainer,
|
|
21
|
+
F as Upload,
|
|
22
|
+
S as Zoom,
|
|
23
|
+
T as canvasCountdown,
|
|
24
|
+
f as chunk,
|
|
25
|
+
h as collapseToast,
|
|
26
|
+
v as cssTransition,
|
|
27
|
+
B as getBackendUrl,
|
|
28
|
+
I as getInitialParticipant,
|
|
29
|
+
U as getParam,
|
|
30
|
+
w as getPlatform,
|
|
31
|
+
y as getSimulation,
|
|
32
|
+
D as isDesktop,
|
|
33
|
+
R as isFullscreen,
|
|
34
|
+
q as noopSimulate,
|
|
35
|
+
A as now,
|
|
36
|
+
M as orchestrateSimulation,
|
|
37
|
+
Q as pipe,
|
|
38
|
+
Z as registerArrayExtensions,
|
|
39
|
+
b as registerComponentParams,
|
|
40
|
+
j as registerExperimentParams,
|
|
41
|
+
z as registerFlattener,
|
|
42
|
+
G as registerSimulation,
|
|
43
|
+
H as resolveSimulation,
|
|
44
|
+
J as sample,
|
|
45
|
+
K as setBackendUrl,
|
|
46
|
+
L as shuffle,
|
|
47
|
+
N as simulateParticipant,
|
|
48
|
+
O as subsetExperimentByParam,
|
|
49
|
+
V as toast,
|
|
50
|
+
X as useToast,
|
|
51
|
+
Y as useToastContainer
|
|
42
52
|
};
|