@adriansteffan/reactive 0.1.34 → 0.2.0
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/.claude/settings.local.json +7 -1
- package/README.md +108 -5
- package/dist/{mod-BpIlYaYt.js → mod-C-XUCKhQ.js} +11574 -11216
- package/dist/mod.d.ts +110 -6
- package/dist/reactive.es.js +74 -63
- package/dist/reactive.umd.js +626 -654
- package/dist/style.css +1 -1
- package/dist/{web-CoJYNnww.js → web-Dpb5MAUc.js} +1 -1
- package/dist/{web-CFP76jkq.js → web-Dv2PC8fG.js} +1 -1
- package/package.json +4 -2
- package/raw-loader-hooks.mjs +25 -0
- package/raw-loader.mjs +5 -0
- package/src/components/experimentrunner.tsx +54 -1
- package/src/components/index.ts +1 -0
- package/src/components/microphonecheck.tsx +70 -84
- package/src/components/text.tsx +1 -1
- package/src/components/upload.tsx +4 -1
- package/src/components/voicerecorder.tsx +184 -162
- package/src/components/voicerecording.tsx +198 -0
- package/src/index.css +6 -0
- package/src/mod.tsx +8 -3
- package/src/utils/array.ts +61 -11
- package/src/utils/audiodevice.ts +4 -0
- package/src/utils/distributions.ts +28 -5
- package/src/utils/llm.ts +101 -0
- package/src/utils/nodecompat.ts +11 -0
- package/src/utils/simulation.ts +2 -2
- package/src/utils/theme.ts +1 -0
- package/src/utils/tts.ts +82 -0
- package/src/utils/upload.ts +65 -5
- package/template/README.md +26 -0
- package/template/backend/src/backend.ts +32 -1
- package/template/docker-compose.yaml +32 -0
- package/template/package.json +5 -2
- package/template/simulate.ts +13 -3
- package/template/src/Experiment.tsx +10 -12
- package/template/transcription/Dockerfile.cpu +8 -0
- package/template/transcription/Dockerfile.gpu +8 -0
- package/template/transcription/transcribe.py +161 -0
- package/vite.config.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adriansteffan/reactive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"import": "./dist/reactive.es.js",
|
|
28
28
|
"require": "./dist/reactive.umd.js",
|
|
29
29
|
"types": "./dist/mod.d.ts"
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"./raw-loader": "./raw-loader.mjs",
|
|
32
|
+
"./raw-loader-hooks": "./raw-loader-hooks.mjs"
|
|
31
33
|
},
|
|
32
34
|
"author": "Adrian Steffan",
|
|
33
35
|
"license": "MIT",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Loader hooks for handling Vite's ?raw import suffix in Node.
|
|
2
|
+
// Strips ?raw from specifiers and returns file contents as string exports.
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const RAW_PATTERN = /\?raw$/;
|
|
7
|
+
const RAW_EXTENSIONS = ['.csv', '.txt', '.svg', '.glsl', '.md'];
|
|
8
|
+
|
|
9
|
+
export function resolve(specifier, context, nextResolve) {
|
|
10
|
+
if (RAW_PATTERN.test(specifier)) {
|
|
11
|
+
return nextResolve(specifier.replace(RAW_PATTERN, ''), context);
|
|
12
|
+
}
|
|
13
|
+
return nextResolve(specifier, context);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function load(url, context, nextLoad) {
|
|
17
|
+
try {
|
|
18
|
+
const path = fileURLToPath(url);
|
|
19
|
+
if (RAW_EXTENSIONS.some(ext => path.endsWith(ext))) {
|
|
20
|
+
const content = readFileSync(path, 'utf8');
|
|
21
|
+
return { format: 'module', source: `export default ${JSON.stringify(content)};`, shortCircuit: true };
|
|
22
|
+
}
|
|
23
|
+
} catch { /* not a file URL, pass through */ }
|
|
24
|
+
return nextLoad(url, context);
|
|
25
|
+
}
|
package/raw-loader.mjs
ADDED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
} from '../utils/simulation';
|
|
19
19
|
import { useHybridSimulationDisabled } from './experimentprovider';
|
|
20
20
|
import { ThemeContext, t } from '../utils/theme';
|
|
21
|
+
import { AudioDeviceContext } from '../utils/audiodevice';
|
|
22
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
21
23
|
|
|
22
24
|
import Upload from './upload';
|
|
23
25
|
import Text from './text';
|
|
@@ -36,6 +38,7 @@ import React from 'react';
|
|
|
36
38
|
import StoreUI from './storeui';
|
|
37
39
|
import { Tutorial } from './tutorial';
|
|
38
40
|
import { RandomDotKinematogram } from './randomdotkinetogram';
|
|
41
|
+
import VoiceRecording from './voicerecording';
|
|
39
42
|
|
|
40
43
|
type ComponentsMap = {
|
|
41
44
|
[key: string]: ComponentType<any>;
|
|
@@ -56,6 +59,7 @@ const defaultComponents: ComponentsMap = {
|
|
|
56
59
|
StoreUI,
|
|
57
60
|
Tutorial,
|
|
58
61
|
RandomDotKinematogram,
|
|
62
|
+
VoiceRecording,
|
|
59
63
|
};
|
|
60
64
|
|
|
61
65
|
const defaultCustomQuestions: ComponentsMap = {
|
|
@@ -77,6 +81,9 @@ interface RuntimeComponentContent {
|
|
|
77
81
|
simulators?: Record<string, any>;
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
// Register dev param globally so it appears in the settings screen
|
|
85
|
+
getParam('dev', false, 'boolean', 'Enable the developer inspector panel');
|
|
86
|
+
|
|
80
87
|
function isRuntimeComponentContent(content: any): content is RuntimeComponentContent {
|
|
81
88
|
return typeof content === 'object' && content !== null && typeof content.type === 'string';
|
|
82
89
|
}
|
|
@@ -89,12 +96,19 @@ export default function ExperimentRunner({
|
|
|
89
96
|
components = {},
|
|
90
97
|
questions = {},
|
|
91
98
|
hybridParticipant,
|
|
99
|
+
disableDev = false,
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
101
|
+
simulationConfig: _simulationConfig,
|
|
92
102
|
}: {
|
|
93
103
|
timeline: TimelineItem[];
|
|
94
104
|
config?: ExperimentConfig;
|
|
95
105
|
components?: ComponentsMap;
|
|
96
106
|
questions?: ComponentsMap;
|
|
97
107
|
hybridParticipant?: ParticipantState;
|
|
108
|
+
/** Disable the ?dev=true inspector panel. Set to true for production. */
|
|
109
|
+
disableDev?: boolean;
|
|
110
|
+
/** Simulation config — not used at runtime, extracted by simulate.ts via createElement. */
|
|
111
|
+
simulationConfig?: any;
|
|
98
112
|
}) {
|
|
99
113
|
const disableHybridSimulation = useHybridSimulationDisabled();
|
|
100
114
|
const trialByteCode = useMemo(() => {
|
|
@@ -153,7 +167,7 @@ export default function ExperimentRunner({
|
|
|
153
167
|
|
|
154
168
|
const [totalTrialsCompleted, setTotalTrialsCompleted] = useState(0);
|
|
155
169
|
const lastTrialEndTimeRef = useRef(now());
|
|
156
|
-
const experimentStoreRef = useRef<Store>({});
|
|
170
|
+
const experimentStoreRef = useRef<Store>({ _uploadId: uuidv4() });
|
|
157
171
|
|
|
158
172
|
const [instructionPointer, setInstructionPointer] = useState(() =>
|
|
159
173
|
advanceToNextContent(
|
|
@@ -390,6 +404,7 @@ export default function ExperimentRunner({
|
|
|
390
404
|
updateStore={updateStore}
|
|
391
405
|
store={experimentStoreRef.current}
|
|
392
406
|
data={dataRef.current}
|
|
407
|
+
name={content.name}
|
|
393
408
|
{...(content.type === 'Quest' ? { customQuestions: customQuestionsMap } : {})}
|
|
394
409
|
{...componentProps}
|
|
395
410
|
/>
|
|
@@ -410,8 +425,13 @@ export default function ExperimentRunner({
|
|
|
410
425
|
const themeValue = config.theme ?? 'light';
|
|
411
426
|
const th = t(themeValue);
|
|
412
427
|
|
|
428
|
+
const showDev = !disableDev && getParam('dev', false, 'boolean');
|
|
429
|
+
const devPanelRef = useRef<HTMLDivElement>(null);
|
|
430
|
+
const devContent = currentInstruction?.type === 'ExecuteContent' ? currentInstruction.content : null;
|
|
431
|
+
|
|
413
432
|
return (
|
|
414
433
|
<ThemeContext.Provider value={themeValue}>
|
|
434
|
+
<AudioDeviceContext.Provider value={experimentStoreRef.current.audioInputId}>
|
|
415
435
|
<div className='w-full h-full'>
|
|
416
436
|
<div
|
|
417
437
|
className={` ${
|
|
@@ -434,7 +454,40 @@ export default function ExperimentRunner({
|
|
|
434
454
|
</div>
|
|
435
455
|
</div>
|
|
436
456
|
{componentToRender}
|
|
457
|
+
{showDev && (
|
|
458
|
+
<>
|
|
459
|
+
<button
|
|
460
|
+
onClick={(e) => {
|
|
461
|
+
const panel = devPanelRef.current;
|
|
462
|
+
if (panel) {
|
|
463
|
+
const open = panel.style.display === 'none';
|
|
464
|
+
panel.style.display = open ? 'block' : 'none';
|
|
465
|
+
(e.currentTarget as HTMLButtonElement).textContent = open ? '\u2715' : 'DEV';
|
|
466
|
+
}
|
|
467
|
+
}}
|
|
468
|
+
className='fixed top-2 right-2 z-50 px-3 py-1 bg-white text-black text-xs font-bold border-2 border-black shadow-[2px_2px_0px_rgba(0,0,0,1)] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-none cursor-pointer'
|
|
469
|
+
>
|
|
470
|
+
DEV
|
|
471
|
+
</button>
|
|
472
|
+
<div ref={devPanelRef} style={{ display: 'none' }} className='fixed top-10 right-2 z-50 w-96 max-h-[80vh] overflow-auto bg-white text-black text-xs font-mono border-2 border-black shadow-[4px_4px_0px_rgba(0,0,0,1)] p-3'>
|
|
473
|
+
{devContent && <>
|
|
474
|
+
<div className='font-bold mb-2 text-sm'>{(devContent as any).type} {(devContent as any).name ? `(${(devContent as any).name})` : ''}</div>
|
|
475
|
+
<div className='mb-2'><span className='font-bold'>Props:</span><pre className='mt-1 whitespace-pre-wrap break-all'>{JSON.stringify(typeof (devContent as any).props === 'function' ? '(dynamic)' : (devContent as any).props, null, 2)}</pre></div>
|
|
476
|
+
{(devContent as any).metadata && <div className='mb-2'><span className='font-bold'>Metadata:</span><pre className='mt-1 whitespace-pre-wrap break-all'>{JSON.stringify((devContent as any).metadata, null, 2)}</pre></div>}
|
|
477
|
+
<div className='mb-2'><span className='font-bold'>Store:</span><pre className='mt-1 whitespace-pre-wrap break-all'>{JSON.stringify(experimentStoreRef.current, null, 2)}</pre></div>
|
|
478
|
+
<div>
|
|
479
|
+
<span className='font-bold cursor-pointer' onClick={(e) => {
|
|
480
|
+
const el = (e.currentTarget as HTMLElement).nextElementSibling as HTMLElement;
|
|
481
|
+
if (el) el.style.display = el.style.display === 'none' ? 'block' : 'none';
|
|
482
|
+
}}>Data ({dataRef.current.length}) ▸</span>
|
|
483
|
+
<pre style={{ display: 'none' }} className='mt-1 whitespace-pre-wrap break-all'>{JSON.stringify(dataRef.current, null, 2)}</pre>
|
|
484
|
+
</div>
|
|
485
|
+
</>}
|
|
486
|
+
</div>
|
|
487
|
+
</>
|
|
488
|
+
)}
|
|
437
489
|
</div>
|
|
490
|
+
</AudioDeviceContext.Provider>
|
|
438
491
|
</ThemeContext.Provider>
|
|
439
492
|
);
|
|
440
493
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -13,5 +13,6 @@ export { default as CanvasBlock } from './canvasblock';
|
|
|
13
13
|
export { default as CheckDevice } from './checkdevice';
|
|
14
14
|
export { Tutorial, useTutorialSlide } from './tutorial';
|
|
15
15
|
export type { TutorialProps } from './tutorial';
|
|
16
|
+
export { default as VoiceRecording } from './voicerecording';
|
|
16
17
|
export { RandomDotKinematogram, RDKCanvas } from './randomdotkinetogram';
|
|
17
18
|
export type { RDKCanvasProps, RDKCanvasHandle, RDKProps, RDKMessage, RDKFeedback, NoiseMovement } from './randomdotkinetogram';
|
|
@@ -2,6 +2,8 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import { VoiceRecorder } from './voicerecorder';
|
|
3
3
|
import { registerSimulation, noopSimulate } from '../utils/simulation';
|
|
4
4
|
import { registerFlattener } from '../utils/upload';
|
|
5
|
+
import { BaseComponentProps } from '../utils/common';
|
|
6
|
+
import { useTheme, t } from '../utils/theme';
|
|
5
7
|
|
|
6
8
|
registerFlattener('MicrophoneCheck', 'session');
|
|
7
9
|
registerSimulation('MicrophoneCheck', noopSimulate, {});
|
|
@@ -11,20 +13,23 @@ interface MicrophoneDevice {
|
|
|
11
13
|
label: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
function MicrophoneSelect({
|
|
15
17
|
onMicrophoneSelect,
|
|
18
|
+
disabled = false,
|
|
16
19
|
}: {
|
|
17
20
|
onMicrophoneSelect: (deviceId: string) => void;
|
|
21
|
+
disabled?: boolean;
|
|
18
22
|
}) {
|
|
23
|
+
const th = t(useTheme());
|
|
19
24
|
const [microphones, setMicrophones] = useState<MicrophoneDevice[]>([]);
|
|
20
25
|
const [selectedMic, setSelectedMic] = useState<string>('');
|
|
21
26
|
const [isOpen, setIsOpen] = useState(false);
|
|
22
27
|
|
|
23
28
|
useEffect(() => {
|
|
24
|
-
// Request microphone permissions and get list of devices
|
|
25
29
|
navigator.mediaDevices
|
|
26
30
|
.getUserMedia({ audio: true })
|
|
27
|
-
.then(() => {
|
|
31
|
+
.then((stream) => {
|
|
32
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
28
33
|
navigator.mediaDevices.enumerateDevices().then((devices) => {
|
|
29
34
|
const mics = devices
|
|
30
35
|
.filter((device) => device.kind === 'audioinput')
|
|
@@ -34,7 +39,6 @@ export function MicrophoneSelect({
|
|
|
34
39
|
}));
|
|
35
40
|
setMicrophones(mics);
|
|
36
41
|
|
|
37
|
-
// Set default microphone
|
|
38
42
|
if (mics.length > 0 && !selectedMic) {
|
|
39
43
|
setSelectedMic(mics[0].deviceId);
|
|
40
44
|
onMicrophoneSelect(mics[0].deviceId);
|
|
@@ -44,7 +48,7 @@ export function MicrophoneSelect({
|
|
|
44
48
|
.catch((err) => {
|
|
45
49
|
console.error('Error accessing microphone:', err);
|
|
46
50
|
});
|
|
47
|
-
}, [
|
|
51
|
+
}, []);
|
|
48
52
|
|
|
49
53
|
const handleSelect = (deviceId: string) => {
|
|
50
54
|
setSelectedMic(deviceId);
|
|
@@ -57,23 +61,9 @@ export function MicrophoneSelect({
|
|
|
57
61
|
|
|
58
62
|
return (
|
|
59
63
|
<div className='relative w-64 mx-auto mt-8 mb-8'>
|
|
60
|
-
{/* Selected Option Display */}
|
|
61
64
|
<button
|
|
62
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
63
|
-
className={`
|
|
64
|
-
w-full px-4 py-2
|
|
65
|
-
bg-white text-black
|
|
66
|
-
border-2 border-black
|
|
67
|
-
shadow-[2px_2px_0px_0px_rgba(0,0,0,1)]
|
|
68
|
-
hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)]
|
|
69
|
-
active:shadow-none
|
|
70
|
-
active:translate-x-1
|
|
71
|
-
active:translate-y-1
|
|
72
|
-
transition-all
|
|
73
|
-
text-left
|
|
74
|
-
font-bold
|
|
75
|
-
${isOpen ? 'shadow-none translate-x-1 translate-y-1' : ''}
|
|
76
|
-
`}
|
|
65
|
+
onClick={() => !disabled && setIsOpen(!isOpen)}
|
|
66
|
+
className={`w-full px-4 py-2 border-2 transition-all text-left font-bold ${th.buttonBg} ${th.buttonBorder} ${th.buttonShadow} ${disabled ? `${th.buttonDisabledText} cursor-default` : `${th.buttonText} cursor-pointer hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] active:shadow-none active:translate-x-1 active:translate-y-1`} ${isOpen ? 'shadow-none translate-x-1 translate-y-1' : ''}`}
|
|
77
67
|
>
|
|
78
68
|
<div className='flex items-center justify-between'>
|
|
79
69
|
<span className='truncate'>{selectedLabel}</span>
|
|
@@ -81,29 +71,14 @@ export function MicrophoneSelect({
|
|
|
81
71
|
</div>
|
|
82
72
|
</button>
|
|
83
73
|
|
|
84
|
-
{/* Dropdown Options */}
|
|
85
74
|
{isOpen && (
|
|
86
75
|
<div className='absolute w-full mt-2 z-50'>
|
|
87
|
-
<ul
|
|
88
|
-
className={`
|
|
89
|
-
bg-white
|
|
90
|
-
border-2 border-black
|
|
91
|
-
shadow-[2px_2px_0px_0px_rgba(0,0,0,1)]
|
|
92
|
-
max-h-60 overflow-auto
|
|
93
|
-
`}
|
|
94
|
-
>
|
|
76
|
+
<ul className={`${th.buttonBg} border-2 ${th.buttonBorder} ${th.buttonShadow} max-h-60 overflow-auto`}>
|
|
95
77
|
{microphones.map((mic) => (
|
|
96
78
|
<li
|
|
97
79
|
key={mic.deviceId}
|
|
98
80
|
onClick={() => handleSelect(mic.deviceId)}
|
|
99
|
-
className={`
|
|
100
|
-
px-4 py-2
|
|
101
|
-
cursor-pointer
|
|
102
|
-
hover:bg-black hover:text-white
|
|
103
|
-
transition-colors
|
|
104
|
-
${selectedMic === mic.deviceId ? 'bg-black text-white' : ''}
|
|
105
|
-
border-b-2 border-black last:border-b-0
|
|
106
|
-
`}
|
|
81
|
+
className={`px-4 py-2 cursor-pointer hover:bg-black hover:text-white transition-colors ${selectedMic === mic.deviceId ? 'bg-black text-white' : th.buttonText} border-b-2 ${th.buttonBorder} last:border-b-0`}
|
|
107
82
|
>
|
|
108
83
|
{mic.label}
|
|
109
84
|
</li>
|
|
@@ -115,56 +90,67 @@ export function MicrophoneSelect({
|
|
|
115
90
|
);
|
|
116
91
|
}
|
|
117
92
|
|
|
118
|
-
const MicrophoneCheck = ({ next }:
|
|
93
|
+
const MicrophoneCheck = ({ next, updateStore, animate = false }: BaseComponentProps & { animate?: boolean }) => {
|
|
94
|
+
const th = t(useTheme());
|
|
119
95
|
const [recordingExists, setRecordingExists] = useState(false);
|
|
96
|
+
const [isRecording, setIsRecording] = useState(false);
|
|
97
|
+
const [selectedDeviceId, setSelectedDeviceId] = useState<string | undefined>(undefined);
|
|
98
|
+
|
|
99
|
+
const handleMicSelect = (id: string) => {
|
|
100
|
+
setSelectedDeviceId(id);
|
|
101
|
+
updateStore({ audioInputId: id });
|
|
102
|
+
};
|
|
120
103
|
|
|
121
104
|
return (
|
|
122
|
-
<div className={`
|
|
123
|
-
<
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
</
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
105
|
+
<div className={`min-h-screen ${th.containerBg}`}>
|
|
106
|
+
<div className={`max-w-prose mx-auto mt-20 mb-20 px-4 ${animate ? 'animate-fade-in opacity-0' : ''}`}>
|
|
107
|
+
<article className={`prose prose-2xl ${th.prose} text-xl ${th.text} leading-relaxed`}>
|
|
108
|
+
<h1 className='text-3xl mb-6 font-semibold'>Let's test your microphone!</h1>
|
|
109
|
+
<p>
|
|
110
|
+
In this experiment, you will need to answer some questions verbally. To make sure that we
|
|
111
|
+
don't lose your input, please select your preferred microphone using the menu below...
|
|
112
|
+
</p>
|
|
113
|
+
</article>
|
|
114
|
+
<MicrophoneSelect onMicrophoneSelect={handleMicSelect} disabled={isRecording} />
|
|
115
|
+
|
|
116
|
+
<article className={`prose prose-2xl ${th.prose} text-xl ${th.text} leading-relaxed`}>
|
|
117
|
+
<p>
|
|
118
|
+
... and use the recording button below to make a test recording of your voice. After
|
|
119
|
+
stopping the recording, you can use the play button to play back the audio.
|
|
120
|
+
</p>
|
|
121
|
+
</article>
|
|
122
|
+
|
|
123
|
+
<VoiceRecorder
|
|
124
|
+
onRecordingStart={() => setIsRecording(true)}
|
|
125
|
+
handleSaveVoiceData={() => { setRecordingExists(true); setIsRecording(false); }}
|
|
126
|
+
handleDiscardVoiceData={() => { setRecordingExists(false); setIsRecording(false); }}
|
|
127
|
+
deviceId={selectedDeviceId}
|
|
128
|
+
showPause={false}
|
|
129
|
+
showDiscard={false}
|
|
130
|
+
/>
|
|
131
|
+
|
|
132
|
+
{recordingExists && (
|
|
133
|
+
<div className='animate-fade-in opacity-0'>
|
|
134
|
+
<article className={`prose prose-2xl ${th.prose} text-xl ${th.text} leading-relaxed`}>
|
|
135
|
+
<p>
|
|
136
|
+
Can you hear yourself? Great! You can continue on to the next step. <br /> If you
|
|
137
|
+
can't hear your voice, try one of the other options from the list or check any
|
|
138
|
+
physical mute switches on your microphone. Be sure to also check that your computer
|
|
139
|
+
audio is turned on so you can actually listen back to your test recording!
|
|
140
|
+
</p>
|
|
141
|
+
</article>
|
|
142
|
+
|
|
143
|
+
<div className='mt-16 flex justify-center'>
|
|
144
|
+
<button
|
|
145
|
+
onClick={() => next({})}
|
|
146
|
+
className={`${th.buttonBg} cursor-pointer px-8 py-3 border-2 ${th.buttonBorder} font-bold ${th.buttonText} text-lg rounded-xl ${th.buttonShadow} hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`}
|
|
147
|
+
>
|
|
148
|
+
Next
|
|
149
|
+
</button>
|
|
150
|
+
</div>
|
|
165
151
|
</div>
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
168
154
|
</div>
|
|
169
155
|
);
|
|
170
156
|
};
|
package/src/components/text.tsx
CHANGED
|
@@ -15,7 +15,7 @@ registerSimulation('Text', (trialProps, _experimentState, simulators, participan
|
|
|
15
15
|
return { responseData: result.value, participantState: result.participantState, duration: result.value.reactionTime };
|
|
16
16
|
}, {
|
|
17
17
|
respond: (_input: any, participant: any) => ({
|
|
18
|
-
value: { key: 'button', reactionTime: uniform(500, 2000) },
|
|
18
|
+
value: { key: 'button', time: Date.now(), reactionTime: uniform(500, 2000) },
|
|
19
19
|
participantState: participant,
|
|
20
20
|
}),
|
|
21
21
|
});
|
|
@@ -65,6 +65,7 @@ registerSimulation('Upload', async (trialProps, experimentState, _simulators, pa
|
|
|
65
65
|
|
|
66
66
|
interface UploadPayload {
|
|
67
67
|
sessionId: string;
|
|
68
|
+
_uploadId?: string;
|
|
68
69
|
files: FileUpload[];
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -305,7 +306,7 @@ export default function Upload({
|
|
|
305
306
|
|
|
306
307
|
uploadInitiatedRef.current = true;
|
|
307
308
|
|
|
308
|
-
const sessionIDUpload = sessionID ?? uuidv4();
|
|
309
|
+
const sessionIDUpload = sessionID ?? store?._uploadId ?? uuidv4();
|
|
309
310
|
|
|
310
311
|
const files = buildUploadFiles({
|
|
311
312
|
sessionID: sessionIDUpload,
|
|
@@ -319,6 +320,8 @@ export default function Upload({
|
|
|
319
320
|
try {
|
|
320
321
|
const payload: UploadPayload = {
|
|
321
322
|
sessionId: sessionIDUpload,
|
|
323
|
+
// Include _uploadId so the backend can rename the eager-upload folder
|
|
324
|
+
...(store?._uploadId && store._uploadId !== sessionIDUpload ? { _uploadId: store._uploadId } : {}),
|
|
322
325
|
files: files.map((file) => ({ ...file, encoding: file.encoding ?? 'utf8' })),
|
|
323
326
|
};
|
|
324
327
|
|