@adriansteffan/reactive 0.0.20 → 0.0.22

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,3 +1,5 @@
1
+ import { Capacitor } from "@capacitor/core";
2
+
1
3
  export function now() {
2
4
  return Math.round(performance.now());
3
5
  }
@@ -11,13 +13,14 @@ export function shuffle(array: any[]) {
11
13
  return array;
12
14
  }
13
15
 
14
- export function isDesktop(){
15
- return (window as any).electronAPI !== undefined
16
+ export function isDesktop() {
17
+ return (window as any).electronAPI !== undefined;
16
18
  }
17
19
 
18
20
  // Generic type for all data structures
19
- export interface StudyEvent {
21
+ export interface TrialData {
20
22
  index: number;
23
+ trialNumber: number,
21
24
  type: string;
22
25
  name: string;
23
26
  data: any;
@@ -36,10 +39,13 @@ export interface ExperimentConfig {
36
39
  showProgressBar: boolean;
37
40
  }
38
41
 
42
+ export interface Store { [key: string]: any }
43
+
39
44
  export interface BaseComponentProps {
40
45
  next: (data: object) => void;
41
- data?: object;
42
- metaData?: object;
46
+ data: TrialData[];
47
+ store?: Store;
48
+ updateStore: (mergeIn: Store) => void;
43
49
  }
44
50
 
45
51
  type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
@@ -115,3 +121,17 @@ export function getParam<T extends ParamType>(
115
121
  if (value === undefined || value === null) return defaultValue;
116
122
  return convertValue(value);
117
123
  }
124
+
125
+
126
+
127
+ export type Platform = 'desktop' | 'mobile' | 'web';
128
+
129
+ export const getPlatform = (): Platform => {
130
+ if ((window as any).electronAPI) {
131
+ return 'desktop';
132
+ } else if (Capacitor.isNativePlatform()) {
133
+ return 'mobile';
134
+ } else {
135
+ return 'web';
136
+ }
137
+ };