@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.
- package/dist/{mod-BlYvqdtq.js → mod-DgcCRxWo.js} +6218 -6060
- package/dist/mod.d.ts +70 -19
- package/dist/reactive.es.js +14 -12
- package/dist/reactive.umd.js +32 -31
- package/dist/style.css +1 -1
- package/dist/{web-EvjUSKrQ.js → web-Dtpv_Ihb.js} +1 -1
- package/package.json +1 -1
- package/src/components/experiment.tsx +242 -33
- package/src/components/plaininput.tsx +72 -0
- package/src/components/text.tsx +1 -1
- package/src/components/upload.tsx +10 -24
- package/src/mod.tsx +2 -1
- package/src/utils/common.ts +25 -5
package/src/utils/common.ts
CHANGED
|
@@ -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
|
|
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
|
|
42
|
-
|
|
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
|
+
};
|