writetrack 0.1.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.
@@ -0,0 +1,326 @@
1
+ import { RefObject } from 'react';
2
+
3
+ /**
4
+ * Raw Event Data Structures
5
+ *
6
+ * Defines the structure for raw input events collected during typing sessions.
7
+ * This is the foundation layer containing unprocessed user interaction data.
8
+ */
9
+ /**
10
+ * Raw session data containing all collected events
11
+ */
12
+ interface RawEventData {
13
+ /** Primary keystroke events */
14
+ events: KeystrokeEvent[];
15
+ /** Clipboard operation events (optional) */
16
+ clipboardEvents?: ClipboardEvent[];
17
+ /** Undo/redo operation events (optional) */
18
+ undoRedoEvents?: UndoRedoEvent[];
19
+ /** Text selection events (optional) */
20
+ selectionEvents?: SelectionEvent[];
21
+ /** Final text that was typed */
22
+ rawText: string;
23
+ /** Session start time (unix timestamp) */
24
+ sessionStartTime: number;
25
+ /** Session end time (unix timestamp) */
26
+ sessionEndTime: number;
27
+ }
28
+ /**
29
+ * Individual keystroke event
30
+ */
31
+ interface KeystrokeEvent {
32
+ /** Key identifier (character or key name) */
33
+ key: string;
34
+ /** Physical key code */
35
+ code: string;
36
+ /** Event type */
37
+ type: 'keydown' | 'keyup';
38
+ /** High-precision timestamp (performance.now()) */
39
+ timestamp: number;
40
+ /** Key hold duration (for keyup events) */
41
+ dwellTime?: number;
42
+ /** Time to next key press (for keydown events) */
43
+ flightTime?: number;
44
+ /** Whether this keystroke was part of a correction */
45
+ isCorrection?: boolean;
46
+ /** Whether this keystroke was part of a typing burst */
47
+ isBurst?: boolean;
48
+ /** Window focus state at time of keystroke */
49
+ windowFocused: boolean;
50
+ /** Time since last mouse interaction */
51
+ timeSinceLastMouse: number;
52
+ /** Character position in text at time of keystroke */
53
+ cursorPosition?: number;
54
+ /** Modifier key states */
55
+ modifiers?: ModifierState;
56
+ }
57
+ /**
58
+ * Modifier key states
59
+ */
60
+ interface ModifierState {
61
+ ctrl: boolean;
62
+ alt: boolean;
63
+ shift: boolean;
64
+ meta: boolean;
65
+ }
66
+ /**
67
+ * Clipboard operation event
68
+ */
69
+ interface ClipboardEvent {
70
+ /** Clipboard operation type */
71
+ type: 'copy' | 'paste' | 'cut';
72
+ /** Event timestamp */
73
+ timestamp: number;
74
+ /** Text position where operation occurred */
75
+ position: number;
76
+ /** Length of text affected */
77
+ length: number;
78
+ /** Keyboard shortcut used */
79
+ shortcut: string;
80
+ /** Actual clipboard content (optional for privacy) */
81
+ content?: string;
82
+ /** Text state before operation (optional) */
83
+ beforeText?: string;
84
+ /** Text state after operation (optional) */
85
+ afterText?: string;
86
+ /** Text that was replaced by paste (optional) */
87
+ replacedText?: string;
88
+ /** Range of text replaced by paste (optional) */
89
+ replacedRange?: {
90
+ start: number;
91
+ end: number;
92
+ };
93
+ }
94
+ /**
95
+ * Text selection event
96
+ */
97
+ interface SelectionEvent {
98
+ /** Event type */
99
+ type: 'select';
100
+ /** Event timestamp */
101
+ timestamp: number;
102
+ /** Start position of selection */
103
+ startPosition: number;
104
+ /** End position of selection */
105
+ endPosition: number;
106
+ /** Length of selected text */
107
+ selectedLength: number;
108
+ /** Selected text content (optional for privacy) */
109
+ selectedText?: string;
110
+ /** How the selection was made */
111
+ method: 'mouse' | 'keyboard' | 'programmatic';
112
+ }
113
+ /**
114
+ * Undo/Redo operation event
115
+ */
116
+ interface UndoRedoEvent {
117
+ /** Operation type */
118
+ type: 'undo' | 'redo';
119
+ /** Event timestamp */
120
+ timestamp: number;
121
+ /** Keyboard shortcut used */
122
+ shortcut: string;
123
+ /** Text state before operation */
124
+ beforeText: string;
125
+ /** Text state after operation */
126
+ afterText: string;
127
+ }
128
+
129
+ /**
130
+ * Session Metadata Data Structures
131
+ *
132
+ * Defines metadata for the capture session context.
133
+ */
134
+ /**
135
+ * Session metadata returned by getData()
136
+ */
137
+ interface SessionMetadata {
138
+ /** Tool identification and version */
139
+ tool: ToolInfo;
140
+ /** Target element type (e.g., 'textarea', 'input', 'div') */
141
+ targetElement: string;
142
+ /** Collection timestamp (ISO8601) */
143
+ timestamp: string;
144
+ /** Session duration in milliseconds */
145
+ duration: number;
146
+ }
147
+ /**
148
+ * Tool identification
149
+ */
150
+ interface ToolInfo {
151
+ /** Tool name */
152
+ name: string;
153
+ /** Tool version */
154
+ version: string;
155
+ /** Tool category (internal use — set by training pipeline, not capture SDK) */
156
+ category?: 'human' | 'selenium' | 'playwright' | 'puppeteer' | 'cypress' | 'webdriverio' | 'other';
157
+ }
158
+
159
+ /**
160
+ * WriteTrack Data Schema v2.0.0 - Main Schema Definition
161
+ *
162
+ * This is the unified, versioned schema for all WriteTrack data structures.
163
+ * It provides a single source of truth for data formats across the entire system.
164
+ */
165
+
166
+ /**
167
+ * Main WriteTrack Data Schema Interface
168
+ * This is the top-level structure for all WriteTrack data exports
169
+ */
170
+ interface WriteTrackDataSchema {
171
+ /** Schema version for compatibility and migration */
172
+ version: '2.0.0';
173
+ /** Session metadata */
174
+ metadata: SessionMetadata;
175
+ /** Raw session data (keystrokes, clipboard, selection events) */
176
+ session: RawEventData;
177
+ /** Data quality metrics and validation status */
178
+ quality: DataQualityMetrics;
179
+ /** True when data was captured without a valid license (production use) */
180
+ unlicensed?: boolean;
181
+ }
182
+ /**
183
+ * Data Quality Assessment
184
+ */
185
+ interface DataQualityMetrics {
186
+ /** Overall data quality score (0-1) */
187
+ overallScore: number;
188
+ /** Data completeness percentage */
189
+ completeness: number;
190
+ /** Event sequence consistency validation */
191
+ sequenceValid: boolean;
192
+ /** Timing data integrity status */
193
+ timingValid: boolean;
194
+ /** Session duration in milliseconds */
195
+ sessionDuration: number;
196
+ /** Total number of events collected */
197
+ eventCount: number;
198
+ /** Quality assessment level */
199
+ qualityLevel: 'POOR' | 'FAIR' | 'GOOD' | 'EXCELLENT';
200
+ /** Quality issues identified */
201
+ issues: string[];
202
+ /** Validation timestamp */
203
+ validatedAt: string;
204
+ }
205
+
206
+ interface WriteTrackOptions {
207
+ target: HTMLElement;
208
+ license?: string;
209
+ }
210
+ declare class WriteTrack {
211
+ protected keystrokeEvents: KeystrokeEvent[];
212
+ protected clipboardEvents: ClipboardEvent[];
213
+ protected undoRedoEvents: UndoRedoEvent[];
214
+ protected selectionEvents: SelectionEvent[];
215
+ private pendingKeydowns;
216
+ protected lastMouseActivity: number;
217
+ protected sessionStartTime: number;
218
+ protected lastKeyTime: number;
219
+ protected lastKeyUpTime: number;
220
+ protected repeatedKeyTracker: Map<string, number[]>;
221
+ private focusStartTime;
222
+ private lastSelection;
223
+ protected readonly BURST_THRESHOLD = 150;
224
+ protected readonly PAUSE_THRESHOLD = 1000;
225
+ protected readonly CORRECTION_KEYS: Set<string>;
226
+ private readonly targetType;
227
+ protected readonly target: HTMLElement;
228
+ private readonly license?;
229
+ /**
230
+ * Create a WriteTrack instance
231
+ * @param optionsOrTarget - Either an HTMLElement (demo mode) or WriteTrackOptions object
232
+ */
233
+ constructor(optionsOrTarget: WriteTrackOptions | HTMLElement);
234
+ private validateLicenseAsync;
235
+ private setupEventListeners;
236
+ /**
237
+ * Technique 6: Observe target's parent for childList changes.
238
+ * If target is removed from DOM, stop recording.
239
+ */
240
+ private setupTargetObserver;
241
+ private isRecordingEnabled;
242
+ private recordKeydown;
243
+ private recordKeyup;
244
+ private recordMouseActivity;
245
+ private recordWindowFocus;
246
+ private detectKeyboardShortcuts;
247
+ private recordClipboardEvent;
248
+ private recordSelection;
249
+ private checkSelectionAfterMouse;
250
+ private recordSelectionChange;
251
+ private getSelection;
252
+ private getSelectedTextLength;
253
+ private recordVisibilityChange;
254
+ private getShortcutString;
255
+ private getCurrentCursorPosition;
256
+ private isMacPlatform;
257
+ private trackRepeatedKey;
258
+ /**
259
+ * Check if the license is valid
260
+ */
261
+ isLicenseValid(): boolean;
262
+ /**
263
+ * Check if license validation has completed
264
+ */
265
+ isLicenseValidated(): boolean;
266
+ /**
267
+ * Check if the target element was detached from the DOM
268
+ */
269
+ isTargetDetached(): boolean;
270
+ start(): void;
271
+ stop(): void;
272
+ getRawEvents(): KeystrokeEvent[];
273
+ getClipboardEvents(): ClipboardEvent[];
274
+ getUndoRedoEvents(): UndoRedoEvent[];
275
+ getSelectionEvents(): SelectionEvent[];
276
+ getSessionDuration(): number;
277
+ getKeystrokeCount(): number;
278
+ getText(): string;
279
+ getData(): WriteTrackDataSchema;
280
+ }
281
+
282
+ interface UseWriteTrackOptions {
283
+ /** Auto-start tracking when element is available (default: true) */
284
+ autoStart?: boolean;
285
+ }
286
+ interface UseWriteTrackReturn {
287
+ /** Reset the tracker and clear state */
288
+ reset: () => void;
289
+ /** Start tracking (if autoStart was false) */
290
+ start: () => void;
291
+ /** Stop tracking */
292
+ stop: () => void;
293
+ /** Whether the tracker is currently active */
294
+ isTracking: boolean;
295
+ /** Access to the underlying WriteTrack instance */
296
+ tracker: WriteTrack | null;
297
+ }
298
+ /**
299
+ * React hook for WriteTrack keystroke analysis
300
+ *
301
+ * @example
302
+ * ```tsx
303
+ * function EssayForm() {
304
+ * const textareaRef = useRef<HTMLTextAreaElement>(null);
305
+ * const { tracker, isTracking } = useWriteTrack(textareaRef);
306
+ *
307
+ * const handleSubmit = (e: FormEvent) => {
308
+ * e.preventDefault();
309
+ * if (tracker) {
310
+ * const features = tracker.getBehavioralFeatures();
311
+ * console.log('Features:', features);
312
+ * }
313
+ * };
314
+ *
315
+ * return (
316
+ * <form onSubmit={handleSubmit}>
317
+ * <textarea ref={textareaRef} />
318
+ * <button type="submit">Submit</button>
319
+ * </form>
320
+ * );
321
+ * }
322
+ * ```
323
+ */
324
+ declare function useWriteTrack(ref: RefObject<HTMLElement | null>, options?: UseWriteTrackOptions): UseWriteTrackReturn;
325
+
326
+ export { type UseWriteTrackOptions, type UseWriteTrackReturn, useWriteTrack };
@@ -0,0 +1 @@
1
+ import{useEffect as l,useRef as f,useCallback as s,useState as p}from"react";import{WriteTrack as a}from"writetrack";function T(e,o={}){let{autoStart:u=!0}=o,r=f(null),[t,c]=p(!1);l(()=>{if(e.current)return r.current=new a(e.current),u&&(r.current.start(),c(!0)),()=>{var n;(n=r.current)==null||n.stop(),r.current=null,c(!1)}},[e,u]);let i=s(()=>{r.current&&!t&&(r.current.start(),c(!0))},[t]),k=s(()=>{r.current&&t&&(r.current.stop(),c(!1))},[t]);return{reset:s(()=>{var n;e.current&&((n=r.current)==null||n.stop(),r.current=new a(e.current),t&&r.current.start())},[e,t]),start:i,stop:k,isTracking:t,tracker:r.current}}export{T as useWriteTrack};
@@ -0,0 +1,328 @@
1
+ import { Ref, ShallowRef } from 'vue';
2
+
3
+ /**
4
+ * Raw Event Data Structures
5
+ *
6
+ * Defines the structure for raw input events collected during typing sessions.
7
+ * This is the foundation layer containing unprocessed user interaction data.
8
+ */
9
+ /**
10
+ * Raw session data containing all collected events
11
+ */
12
+ interface RawEventData {
13
+ /** Primary keystroke events */
14
+ events: KeystrokeEvent[];
15
+ /** Clipboard operation events (optional) */
16
+ clipboardEvents?: ClipboardEvent[];
17
+ /** Undo/redo operation events (optional) */
18
+ undoRedoEvents?: UndoRedoEvent[];
19
+ /** Text selection events (optional) */
20
+ selectionEvents?: SelectionEvent[];
21
+ /** Final text that was typed */
22
+ rawText: string;
23
+ /** Session start time (unix timestamp) */
24
+ sessionStartTime: number;
25
+ /** Session end time (unix timestamp) */
26
+ sessionEndTime: number;
27
+ }
28
+ /**
29
+ * Individual keystroke event
30
+ */
31
+ interface KeystrokeEvent {
32
+ /** Key identifier (character or key name) */
33
+ key: string;
34
+ /** Physical key code */
35
+ code: string;
36
+ /** Event type */
37
+ type: 'keydown' | 'keyup';
38
+ /** High-precision timestamp (performance.now()) */
39
+ timestamp: number;
40
+ /** Key hold duration (for keyup events) */
41
+ dwellTime?: number;
42
+ /** Time to next key press (for keydown events) */
43
+ flightTime?: number;
44
+ /** Whether this keystroke was part of a correction */
45
+ isCorrection?: boolean;
46
+ /** Whether this keystroke was part of a typing burst */
47
+ isBurst?: boolean;
48
+ /** Window focus state at time of keystroke */
49
+ windowFocused: boolean;
50
+ /** Time since last mouse interaction */
51
+ timeSinceLastMouse: number;
52
+ /** Character position in text at time of keystroke */
53
+ cursorPosition?: number;
54
+ /** Modifier key states */
55
+ modifiers?: ModifierState;
56
+ }
57
+ /**
58
+ * Modifier key states
59
+ */
60
+ interface ModifierState {
61
+ ctrl: boolean;
62
+ alt: boolean;
63
+ shift: boolean;
64
+ meta: boolean;
65
+ }
66
+ /**
67
+ * Clipboard operation event
68
+ */
69
+ interface ClipboardEvent {
70
+ /** Clipboard operation type */
71
+ type: 'copy' | 'paste' | 'cut';
72
+ /** Event timestamp */
73
+ timestamp: number;
74
+ /** Text position where operation occurred */
75
+ position: number;
76
+ /** Length of text affected */
77
+ length: number;
78
+ /** Keyboard shortcut used */
79
+ shortcut: string;
80
+ /** Actual clipboard content (optional for privacy) */
81
+ content?: string;
82
+ /** Text state before operation (optional) */
83
+ beforeText?: string;
84
+ /** Text state after operation (optional) */
85
+ afterText?: string;
86
+ /** Text that was replaced by paste (optional) */
87
+ replacedText?: string;
88
+ /** Range of text replaced by paste (optional) */
89
+ replacedRange?: {
90
+ start: number;
91
+ end: number;
92
+ };
93
+ }
94
+ /**
95
+ * Text selection event
96
+ */
97
+ interface SelectionEvent {
98
+ /** Event type */
99
+ type: 'select';
100
+ /** Event timestamp */
101
+ timestamp: number;
102
+ /** Start position of selection */
103
+ startPosition: number;
104
+ /** End position of selection */
105
+ endPosition: number;
106
+ /** Length of selected text */
107
+ selectedLength: number;
108
+ /** Selected text content (optional for privacy) */
109
+ selectedText?: string;
110
+ /** How the selection was made */
111
+ method: 'mouse' | 'keyboard' | 'programmatic';
112
+ }
113
+ /**
114
+ * Undo/Redo operation event
115
+ */
116
+ interface UndoRedoEvent {
117
+ /** Operation type */
118
+ type: 'undo' | 'redo';
119
+ /** Event timestamp */
120
+ timestamp: number;
121
+ /** Keyboard shortcut used */
122
+ shortcut: string;
123
+ /** Text state before operation */
124
+ beforeText: string;
125
+ /** Text state after operation */
126
+ afterText: string;
127
+ }
128
+
129
+ /**
130
+ * Session Metadata Data Structures
131
+ *
132
+ * Defines metadata for the capture session context.
133
+ */
134
+ /**
135
+ * Session metadata returned by getData()
136
+ */
137
+ interface SessionMetadata {
138
+ /** Tool identification and version */
139
+ tool: ToolInfo;
140
+ /** Target element type (e.g., 'textarea', 'input', 'div') */
141
+ targetElement: string;
142
+ /** Collection timestamp (ISO8601) */
143
+ timestamp: string;
144
+ /** Session duration in milliseconds */
145
+ duration: number;
146
+ }
147
+ /**
148
+ * Tool identification
149
+ */
150
+ interface ToolInfo {
151
+ /** Tool name */
152
+ name: string;
153
+ /** Tool version */
154
+ version: string;
155
+ /** Tool category (internal use — set by training pipeline, not capture SDK) */
156
+ category?: 'human' | 'selenium' | 'playwright' | 'puppeteer' | 'cypress' | 'webdriverio' | 'other';
157
+ }
158
+
159
+ /**
160
+ * WriteTrack Data Schema v2.0.0 - Main Schema Definition
161
+ *
162
+ * This is the unified, versioned schema for all WriteTrack data structures.
163
+ * It provides a single source of truth for data formats across the entire system.
164
+ */
165
+
166
+ /**
167
+ * Main WriteTrack Data Schema Interface
168
+ * This is the top-level structure for all WriteTrack data exports
169
+ */
170
+ interface WriteTrackDataSchema {
171
+ /** Schema version for compatibility and migration */
172
+ version: '2.0.0';
173
+ /** Session metadata */
174
+ metadata: SessionMetadata;
175
+ /** Raw session data (keystrokes, clipboard, selection events) */
176
+ session: RawEventData;
177
+ /** Data quality metrics and validation status */
178
+ quality: DataQualityMetrics;
179
+ /** True when data was captured without a valid license (production use) */
180
+ unlicensed?: boolean;
181
+ }
182
+ /**
183
+ * Data Quality Assessment
184
+ */
185
+ interface DataQualityMetrics {
186
+ /** Overall data quality score (0-1) */
187
+ overallScore: number;
188
+ /** Data completeness percentage */
189
+ completeness: number;
190
+ /** Event sequence consistency validation */
191
+ sequenceValid: boolean;
192
+ /** Timing data integrity status */
193
+ timingValid: boolean;
194
+ /** Session duration in milliseconds */
195
+ sessionDuration: number;
196
+ /** Total number of events collected */
197
+ eventCount: number;
198
+ /** Quality assessment level */
199
+ qualityLevel: 'POOR' | 'FAIR' | 'GOOD' | 'EXCELLENT';
200
+ /** Quality issues identified */
201
+ issues: string[];
202
+ /** Validation timestamp */
203
+ validatedAt: string;
204
+ }
205
+
206
+ interface WriteTrackOptions {
207
+ target: HTMLElement;
208
+ license?: string;
209
+ }
210
+ declare class WriteTrack {
211
+ protected keystrokeEvents: KeystrokeEvent[];
212
+ protected clipboardEvents: ClipboardEvent[];
213
+ protected undoRedoEvents: UndoRedoEvent[];
214
+ protected selectionEvents: SelectionEvent[];
215
+ private pendingKeydowns;
216
+ protected lastMouseActivity: number;
217
+ protected sessionStartTime: number;
218
+ protected lastKeyTime: number;
219
+ protected lastKeyUpTime: number;
220
+ protected repeatedKeyTracker: Map<string, number[]>;
221
+ private focusStartTime;
222
+ private lastSelection;
223
+ protected readonly BURST_THRESHOLD = 150;
224
+ protected readonly PAUSE_THRESHOLD = 1000;
225
+ protected readonly CORRECTION_KEYS: Set<string>;
226
+ private readonly targetType;
227
+ protected readonly target: HTMLElement;
228
+ private readonly license?;
229
+ /**
230
+ * Create a WriteTrack instance
231
+ * @param optionsOrTarget - Either an HTMLElement (demo mode) or WriteTrackOptions object
232
+ */
233
+ constructor(optionsOrTarget: WriteTrackOptions | HTMLElement);
234
+ private validateLicenseAsync;
235
+ private setupEventListeners;
236
+ /**
237
+ * Technique 6: Observe target's parent for childList changes.
238
+ * If target is removed from DOM, stop recording.
239
+ */
240
+ private setupTargetObserver;
241
+ private isRecordingEnabled;
242
+ private recordKeydown;
243
+ private recordKeyup;
244
+ private recordMouseActivity;
245
+ private recordWindowFocus;
246
+ private detectKeyboardShortcuts;
247
+ private recordClipboardEvent;
248
+ private recordSelection;
249
+ private checkSelectionAfterMouse;
250
+ private recordSelectionChange;
251
+ private getSelection;
252
+ private getSelectedTextLength;
253
+ private recordVisibilityChange;
254
+ private getShortcutString;
255
+ private getCurrentCursorPosition;
256
+ private isMacPlatform;
257
+ private trackRepeatedKey;
258
+ /**
259
+ * Check if the license is valid
260
+ */
261
+ isLicenseValid(): boolean;
262
+ /**
263
+ * Check if license validation has completed
264
+ */
265
+ isLicenseValidated(): boolean;
266
+ /**
267
+ * Check if the target element was detached from the DOM
268
+ */
269
+ isTargetDetached(): boolean;
270
+ start(): void;
271
+ stop(): void;
272
+ getRawEvents(): KeystrokeEvent[];
273
+ getClipboardEvents(): ClipboardEvent[];
274
+ getUndoRedoEvents(): UndoRedoEvent[];
275
+ getSelectionEvents(): SelectionEvent[];
276
+ getSessionDuration(): number;
277
+ getKeystrokeCount(): number;
278
+ getText(): string;
279
+ getData(): WriteTrackDataSchema;
280
+ }
281
+
282
+ interface UseWriteTrackOptions {
283
+ /** Auto-start tracking when element is available (default: true) */
284
+ autoStart?: boolean;
285
+ }
286
+ interface UseWriteTrackReturn {
287
+ /** Reset the tracker and clear state */
288
+ reset: () => void;
289
+ /** Start tracking (if autoStart was false) */
290
+ start: () => void;
291
+ /** Stop tracking */
292
+ stop: () => void;
293
+ /** Whether the tracker is currently active */
294
+ isTracking: Ref<boolean>;
295
+ /** Access to the underlying WriteTrack instance */
296
+ tracker: ShallowRef<WriteTrack | null>;
297
+ }
298
+ /**
299
+ * Vue 3 composable for WriteTrack keystroke analysis
300
+ *
301
+ * @example
302
+ * ```vue
303
+ * <script setup lang="ts">
304
+ * import { ref } from 'vue';
305
+ * import { useWriteTrack } from 'writetrack/vue';
306
+ *
307
+ * const textareaRef = ref<HTMLTextAreaElement | null>(null);
308
+ * const { tracker, isTracking } = useWriteTrack(textareaRef);
309
+ *
310
+ * function handleSubmit() {
311
+ * if (tracker.value) {
312
+ * const features = tracker.value.getBehavioralFeatures();
313
+ * console.log('Features:', features);
314
+ * }
315
+ * }
316
+ * </script>
317
+ *
318
+ * <template>
319
+ * <form @submit.prevent="handleSubmit">
320
+ * <textarea ref="textareaRef" />
321
+ * <button type="submit">Submit</button>
322
+ * </form>
323
+ * </template>
324
+ * ```
325
+ */
326
+ declare function useWriteTrack(elementRef: Ref<HTMLElement | null>, options?: UseWriteTrackOptions): UseWriteTrackReturn;
327
+
328
+ export { type UseWriteTrackOptions, type UseWriteTrackReturn, useWriteTrack };
@@ -0,0 +1 @@
1
+ import{ref as v,onMounted as k,onUnmounted as p,shallowRef as T}from"vue";import{WriteTrack as u}from"writetrack";function W(r,o={}){let{autoStart:n=!0}=o,e=T(null),t=v(!1);function l(){r.value&&(e.value=new u(r.value),n&&(e.value.start(),t.value=!0))}function a(){e.value&&(e.value.stop(),e.value=null,t.value=!1)}k(()=>{l()}),p(()=>{a()});function i(){e.value&&!t.value&&(e.value.start(),t.value=!0)}function s(){e.value&&t.value&&(e.value.stop(),t.value=!1)}function c(){if(!r.value)return;let f=t.value;a(),e.value=new u(r.value),f&&(e.value.start(),t.value=!0)}return{reset:c,start:i,stop:s,isTracking:t,tracker:e}}export{W as useWriteTrack};