@adriansteffan/reactive 0.0.42 → 0.0.44

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.
Files changed (37) hide show
  1. package/.claude/settings.local.json +11 -2
  2. package/README.md +106 -3
  3. package/dist/{mod-UqYdghJl.js → mod-D6DlS3ur.js} +6483 -6120
  4. package/dist/mod.d.ts +54 -2
  5. package/dist/reactive.es.js +42 -33
  6. package/dist/reactive.umd.js +38 -36
  7. package/dist/style.css +1 -1
  8. package/dist/{web-pL-YTTVv.js → web-D7VcCd-t.js} +1 -1
  9. package/dist/{web-eGzX65_f.js → web-o3I0sgwu.js} +1 -1
  10. package/package.json +1 -1
  11. package/src/components/canvasblock.tsx +112 -70
  12. package/src/components/checkdevice.tsx +15 -0
  13. package/src/components/enterfullscreen.tsx +5 -3
  14. package/src/components/exitfullscreen.tsx +4 -1
  15. package/src/components/experimentprovider.tsx +7 -2
  16. package/src/components/experimentrunner.tsx +66 -52
  17. package/src/components/microphonecheck.tsx +3 -0
  18. package/src/components/mobilefilepermission.tsx +3 -0
  19. package/src/components/plaininput.tsx +17 -0
  20. package/src/components/prolificending.tsx +3 -0
  21. package/src/components/quest.tsx +58 -8
  22. package/src/components/storeui.tsx +15 -11
  23. package/src/components/text.tsx +11 -0
  24. package/src/components/upload.tsx +56 -271
  25. package/src/mod.tsx +1 -0
  26. package/src/utils/bytecode.ts +50 -0
  27. package/src/utils/simulation.ts +268 -0
  28. package/src/utils/upload.ts +299 -0
  29. package/template/README.md +59 -0
  30. package/template/backend/src/backend.ts +1 -0
  31. package/template/package.json +2 -0
  32. package/template/simulate.ts +15 -0
  33. package/template/src/Experiment.tsx +58 -5
  34. package/template/src/main.tsx +1 -1
  35. package/template/tsconfig.json +2 -3
  36. package/tsconfig.json +1 -0
  37. package/vite.config.ts +1 -1
package/dist/mod.d.ts CHANGED
@@ -57,6 +57,11 @@ declare type ComponentResultData = BaseTrialData & {
57
57
  metadata?: Record<string, any>;
58
58
  };
59
59
 
60
+ declare interface ComponentSimulation {
61
+ simulate: SimulateFunction;
62
+ defaultSimulators: Record<string, any>;
63
+ }
64
+
60
65
  declare type ComponentsMap = {
61
66
  [key: string]: ComponentType<any>;
62
67
  };
@@ -105,16 +110,18 @@ export declare interface ExperimentConfig {
105
110
  showProgressBar: boolean;
106
111
  }
107
112
 
108
- export declare function ExperimentProvider({ children, disableSettings }: {
113
+ export declare function ExperimentProvider({ children, disableSettings, disableHybridSimulation }: {
109
114
  children: ReactNode;
110
115
  disableSettings?: boolean;
116
+ disableHybridSimulation?: boolean;
111
117
  }): JSX_2.Element;
112
118
 
113
- export declare function ExperimentRunner({ timeline, config, components, questions, }: {
119
+ export declare function ExperimentRunner({ timeline, config, components, questions, hybridParticipant, }: {
114
120
  timeline: TimelineItem[];
115
121
  config?: ExperimentConfig;
116
122
  components?: ComponentsMap_2;
117
123
  questions?: ComponentsMap_2;
124
+ hybridParticipant?: ParticipantState;
118
125
  }): JSX_2.Element;
119
126
 
120
127
  export declare interface FileUpload {
@@ -123,10 +130,16 @@ export declare interface FileUpload {
123
130
  encoding?: 'base64' | 'utf8';
124
131
  }
125
132
 
133
+ export declare function getBackendUrl(): string;
134
+
135
+ export declare function getInitialParticipant(): ParticipantState | undefined;
136
+
126
137
  export declare function getParam<T extends ParamType>(name: string, defaultValue: ParamValue<T>, type?: T, description?: string): ParamValue<T>;
127
138
 
128
139
  export declare const getPlatform: () => Platform;
129
140
 
141
+ export declare function getSimulation(type: string): ComponentSimulation | undefined;
142
+
130
143
  declare interface IfBlockItem {
131
144
  type: 'IF_BLOCK';
132
145
  cond: ConditionalFunction;
@@ -152,8 +165,12 @@ export declare const MicCheck: ({ next }: {
152
165
  next: (data: object) => void;
153
166
  }) => JSX_2.Element;
154
167
 
168
+ export declare const noopSimulate: SimulateFunction;
169
+
155
170
  export declare function now(): number;
156
171
 
172
+ export declare function orchestrateSimulation(config: RunSimulationConfig, scriptPath: string): Promise<void>;
173
+
157
174
  export declare class Param {
158
175
  static getRegistry(): any[];
159
176
  static getTimelineRepresentation(): {
@@ -166,6 +183,8 @@ declare type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
166
183
 
167
184
  declare type ParamValue<T extends ParamType> = T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'array' | 'json' ? any : string;
168
185
 
186
+ export declare type ParticipantState = Record<string, any>;
187
+
169
188
  /**
170
189
  * Applies a function to an array
171
190
  */
@@ -221,18 +240,51 @@ export declare function registerComponentParams(type: string, params: {
221
240
 
222
241
  export declare function registerExperimentParams(experiment: any[]): void;
223
242
 
243
+ export declare function registerSimulation(type: string, simulate: SimulateFunction, defaultSimulators: Record<string, any>): void;
244
+
224
245
  export declare function RequestFilePermission({ next }: BaseComponentProps): JSX_2.Element | null;
225
246
 
247
+ export declare function resolveSimulation(content: any, data: RefinedTrialData[], store: Store_2): {
248
+ trialProps: any;
249
+ simulateFn: any;
250
+ simulators: any;
251
+ };
252
+
253
+ export declare interface RunSimulationConfig {
254
+ participants: ParticipantState[] | {
255
+ generator: (index: number) => ParticipantState;
256
+ count: number;
257
+ };
258
+ backendPort?: number;
259
+ concurrency?: number;
260
+ }
261
+
226
262
  /**
227
263
  * Returns random elements from an array
228
264
  */
229
265
  export declare function sample<T>(array: T[], n?: number): T[];
230
266
 
267
+ export declare function setBackendUrl(url: string): void;
268
+
231
269
  /**
232
270
  * Shuffles array elements using Fisher-Yates algorithm
233
271
  */
234
272
  export declare function shuffle<T>(array: T[]): T[];
235
273
 
274
+ export declare type SimulateFunction = (trialProps: Record<string, any>, experimentState: {
275
+ data: RefinedTrialData[];
276
+ store: Store_2;
277
+ }, simulators: Record<string, any>, participant: ParticipantState) => SimulatorResult | Promise<SimulatorResult>;
278
+
279
+ export declare function simulateParticipant(timeline: TimelineItem[], participant: ParticipantState): Promise<RefinedTrialData[]>;
280
+
281
+ export declare type SimulatorResult = {
282
+ responseData: any;
283
+ participantState: ParticipantState;
284
+ storeUpdates?: Record<string, any>;
285
+ duration?: number;
286
+ };
287
+
236
288
  export declare interface Store {
237
289
  [key: string]: any;
238
290
  }
@@ -1,42 +1,51 @@
1
- import { H as e, C as n, v as r, o as t, q as i, t as o, u as l, Y as c, z as m, M as p, P as u, l as P, m as x, Q as C, R as E, F as g, T, w as d, U as f, X as k, k as F, c as h, x as v, y as B, g as w, e as y, d as R, i as q, n as D, p as I, r as M, h as Q, f as U, s as b, a as j, j as z, B as A, N as H, L } from "./mod-UqYdghJl.js";
1
+ import { H as e, F as t, G as i, A as n, B as r, C as o, D as l, Y as m, I as c, M as u, P as p, y as P, z as g, Q as x, R as d, J as k, T as C, K as E, U as S, X as T, k as f, c as h, L as v, N as B, u as F, v as I, g as U, e as w, m as y, d as D, i as R, o as q, n as A, x as M, p as Q, r as b, h as j, f as z, l as G, q as H, s as J, t as K, a as L, w as N, j as O, O as V, S as X, V as Y } from "./mod-D6DlS3ur.js";
2
2
  export {
3
3
  e as Bounce,
4
- n as CanvasBlock,
5
- r as CheckDevice,
6
- t as EnterFullscreen,
7
- i as ExitFullscreen,
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
- c as Flip,
11
- m as Icons,
12
- p as MicCheck,
13
- u as Param,
10
+ m as Flip,
11
+ c as Icons,
12
+ u as MicCheck,
13
+ p as Param,
14
14
  P as PlainInput,
15
- x as ProlificEnding,
16
- C as Quest,
17
- E as RequestFilePermission,
18
- g as Slide,
19
- T as Text,
20
- d as ToastContainer,
21
- f as Upload,
22
- k as Zoom,
23
- F as canvasCountdown,
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
+ S as Upload,
22
+ T as Zoom,
23
+ f as canvasCountdown,
24
24
  h as chunk,
25
25
  v as collapseToast,
26
26
  B as cssTransition,
27
- w as getParam,
28
- y as getPlatform,
29
- R as isDesktop,
30
- q as isFullscreen,
31
- D as now,
32
- I as pipe,
33
- M as registerArrayExtensions,
34
- Q as registerComponentParams,
35
- U as registerExperimentParams,
36
- b as sample,
37
- j as shuffle,
38
- z as subsetExperimentByParam,
39
- A as toast,
40
- H as useToast,
41
- L as useToastContainer
27
+ F 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
+ b as registerArrayExtensions,
39
+ j as registerComponentParams,
40
+ z as registerExperimentParams,
41
+ G as registerSimulation,
42
+ H as resolveSimulation,
43
+ J as sample,
44
+ K as setBackendUrl,
45
+ L as shuffle,
46
+ N as simulateParticipant,
47
+ O as subsetExperimentByParam,
48
+ V as toast,
49
+ X as useToast,
50
+ Y as useToastContainer
42
51
  };