@adriansteffan/reactive 0.1.13 → 0.1.15
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-Cu_Zktcq.js → mod-jEMvaWXA.js} +4532 -4509
- package/dist/reactive.es.js +1 -1
- package/dist/reactive.umd.js +619 -619
- package/dist/{web-C5bGJ59T.js → web-CRSMW9BX.js} +1 -1
- package/dist/{web-jzuaNWaD.js → web-CeblAJYh.js} +1 -1
- package/package.json +1 -1
- package/src/components/experimentprovider.tsx +12 -3
- package/src/components/tutorial.tsx +8 -5
- package/src/utils/simulation.ts +13 -1
package/package.json
CHANGED
|
@@ -10,9 +10,18 @@ import { Param } from '../utils/common';
|
|
|
10
10
|
const HybridSimulationContext = createContext(false);
|
|
11
11
|
export const useHybridSimulationDisabled = () => useContext(HybridSimulationContext);
|
|
12
12
|
|
|
13
|
+
function parseBooleanProp(value: unknown): boolean {
|
|
14
|
+
if (typeof value === 'boolean') return value;
|
|
15
|
+
if (typeof value === 'string') {
|
|
16
|
+
const lower = value.trim().toLowerCase();
|
|
17
|
+
return lower !== '' && lower !== 'false' && lower !== '0';
|
|
18
|
+
}
|
|
19
|
+
return !!value;
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
export default function ExperimentProvider({ children, disableSettings, disableHybridSimulation }: { children: ReactNode, disableSettings?: boolean, disableHybridSimulation?: boolean }) {
|
|
14
|
-
|
|
15
|
-
if (window.location.pathname.endsWith('/settings') && !disableSettings) {
|
|
23
|
+
|
|
24
|
+
if (window.location.pathname.endsWith('/settings') && !parseBooleanProp(disableSettings)) {
|
|
16
25
|
return (
|
|
17
26
|
<SettingsScreen
|
|
18
27
|
paramRegistry={Param.getRegistry()}
|
|
@@ -23,7 +32,7 @@ export default function ExperimentProvider({ children, disableSettings, disableH
|
|
|
23
32
|
|
|
24
33
|
return (
|
|
25
34
|
<QueryClientProvider client={queryClient}>
|
|
26
|
-
<HybridSimulationContext.Provider value={
|
|
35
|
+
<HybridSimulationContext.Provider value={parseBooleanProp(disableHybridSimulation)}>
|
|
27
36
|
{children}
|
|
28
37
|
</HybridSimulationContext.Provider>
|
|
29
38
|
<ToastContainer
|
|
@@ -98,9 +98,13 @@ export const Tutorial = ({
|
|
|
98
98
|
const canProgress = progressMap[page] !== false;
|
|
99
99
|
|
|
100
100
|
const prevCanProgress = useRef(canProgress);
|
|
101
|
-
const [
|
|
101
|
+
const [pulse, setPulse] = useState(false);
|
|
102
102
|
useEffect(() => {
|
|
103
|
-
if (canProgress && !prevCanProgress.current)
|
|
103
|
+
if (canProgress && !prevCanProgress.current) {
|
|
104
|
+
setPulse(true);
|
|
105
|
+
const timer = setTimeout(() => setPulse(false), 300);
|
|
106
|
+
return () => clearTimeout(timer);
|
|
107
|
+
}
|
|
104
108
|
prevCanProgress.current = canProgress;
|
|
105
109
|
}, [canProgress]);
|
|
106
110
|
|
|
@@ -226,12 +230,11 @@ export const Tutorial = ({
|
|
|
226
230
|
|
|
227
231
|
<div style={{ justifySelf: 'start', marginLeft: '1rem' }}>
|
|
228
232
|
<motion.button
|
|
229
|
-
key={pulseKey}
|
|
230
233
|
onClick={goNextIfCan}
|
|
231
234
|
tabIndex={-1}
|
|
232
235
|
onKeyDown={(e) => { if (e.key === ' ' || e.key === 'Enter') e.preventDefault(); }}
|
|
233
|
-
animate={{ scale:
|
|
234
|
-
transition={{
|
|
236
|
+
animate={{ scale: pulse ? 1.2 : 1 }}
|
|
237
|
+
transition={{ type: 'spring', stiffness: 500, damping: 15 }}
|
|
235
238
|
className={(canProgress ? NAV_BTN_ACTIVE : NAV_BTN_DISABLED) + (page === slides.length - 1 ? ' px-8' : '')}
|
|
236
239
|
>
|
|
237
240
|
{page === slides.length - 1 ? finishText : '→'}
|
package/src/utils/simulation.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
TimelineItem,
|
|
10
10
|
Store,
|
|
11
11
|
} from './bytecode';
|
|
12
|
+
import { Param } from './common';
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
export type ParticipantState = Record<string, any>;
|
|
@@ -94,7 +95,18 @@ export async function simulateParticipant(
|
|
|
94
95
|
duration: 0,
|
|
95
96
|
type: '',
|
|
96
97
|
name: '',
|
|
97
|
-
responseData: {
|
|
98
|
+
responseData: {
|
|
99
|
+
userAgent: 'simulated',
|
|
100
|
+
params: Object.fromEntries(
|
|
101
|
+
(Param.getRegistry() || []).map((p: any) => [p.name, {
|
|
102
|
+
value: p.value !== undefined ? p.value : p.defaultValue,
|
|
103
|
+
registered: true,
|
|
104
|
+
defaultValue: p.defaultValue,
|
|
105
|
+
type: p.type,
|
|
106
|
+
description: p.description,
|
|
107
|
+
}]),
|
|
108
|
+
),
|
|
109
|
+
},
|
|
98
110
|
},
|
|
99
111
|
];
|
|
100
112
|
|