@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.
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-Cu_Zktcq.js";
1
+ import { W as e } from "./mod-jEMvaWXA.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./mod-Cu_Zktcq.js";
1
+ import { W as P, b as x, E } from "./mod-jEMvaWXA.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -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={!!disableHybridSimulation}>
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 [pulseKey, setPulseKey] = useState(0);
101
+ const [pulse, setPulse] = useState(false);
102
102
  useEffect(() => {
103
- if (canProgress && !prevCanProgress.current) setPulseKey((k) => k + 1);
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: [1, 1.2, 1] }}
234
- transition={{ duration: 0.3 }}
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 : '→'}
@@ -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: { userAgent: 'simulated', params: {} },
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