@nonstrict/recordkit 0.87.1 → 0.97.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.
Files changed (54) hide show
  1. package/bin/README.md +1 -1
  2. package/bin/recordkit-rpc +0 -0
  3. package/out/Errors.d.ts +91 -0
  4. package/out/Errors.js +63 -0
  5. package/out/Errors.js.map +1 -0
  6. package/out/InputEvents.d.ts +661 -0
  7. package/out/InputEvents.js +8 -0
  8. package/out/InputEvents.js.map +1 -0
  9. package/out/IpcRecordKit.js +13 -0
  10. package/out/IpcRecordKit.js.map +1 -1
  11. package/out/NonstrictRPC.d.ts +9 -0
  12. package/out/NonstrictRPC.js +27 -4
  13. package/out/NonstrictRPC.js.map +1 -1
  14. package/out/RecordKit.d.ts +267 -5
  15. package/out/RecordKit.js +243 -3
  16. package/out/RecordKit.js.map +1 -1
  17. package/out/Recorder.d.ts +451 -53
  18. package/out/Recorder.js +80 -2
  19. package/out/Recorder.js.map +1 -1
  20. package/out/RecordingMetadata.d.ts +96 -0
  21. package/out/RecordingMetadata.js +12 -0
  22. package/out/RecordingMetadata.js.map +1 -0
  23. package/out/WebAudioUtils.d.ts +35 -0
  24. package/out/WebAudioUtils.js +37 -0
  25. package/out/WebAudioUtils.js.map +1 -1
  26. package/out/WindowLevels.d.ts +46 -0
  27. package/out/WindowLevels.js +41 -0
  28. package/out/WindowLevels.js.map +1 -0
  29. package/out/browser.d.ts +8 -1
  30. package/out/browser.js +3 -1
  31. package/out/browser.js.map +1 -1
  32. package/out/index.cjs +603 -9
  33. package/out/index.cjs.map +1 -1
  34. package/out/index.d.ts +8 -0
  35. package/out/index.js +3 -0
  36. package/out/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/Errors.test.ts +38 -0
  39. package/src/Errors.ts +151 -0
  40. package/src/InputEvents.ts +695 -0
  41. package/src/IpcRecordKit.ts +12 -0
  42. package/src/NonstrictRPC.test.ts +24 -1
  43. package/src/NonstrictRPC.ts +29 -5
  44. package/src/RecordKit.ts +347 -11
  45. package/src/Recorder.schema.test.ts +167 -0
  46. package/src/Recorder.ts +558 -80
  47. package/src/RecordingMetadata.ts +125 -0
  48. package/src/WebAudioUtils.test.ts +78 -0
  49. package/src/WebAudioUtils.ts +57 -1
  50. package/src/WindowLevels.test.ts +34 -0
  51. package/src/WindowLevels.ts +47 -0
  52. package/src/browser.ts +12 -2
  53. package/src/index.ts +8 -0
  54. package/src/__snapshots__/NonstrictRPC.test.ts.snap +0 -24
@@ -0,0 +1,661 @@
1
+ /**
2
+ * Time an input event occurred in the recording.
3
+ *
4
+ * @group Recording
5
+ */
6
+ export interface EventTime {
7
+ /** The time in seconds. Prefer this field for time math. */
8
+ seconds: number;
9
+ /**
10
+ * The numerator of the rational time value (`value / timescale ≈ seconds`; `value` is the
11
+ * truncated nanosecond count, so {@link EventTime.seconds} is authoritative).
12
+ *
13
+ * This mirrors a 64-bit integer; for extremely long recordings (beyond ~104 days at nanosecond
14
+ * timescale) it can exceed JavaScript's `Number.MAX_SAFE_INTEGER`, so prefer {@link EventTime.seconds}.
15
+ */
16
+ value: number;
17
+ /** The denominator (timescale) of the rational time value. */
18
+ timescale: number;
19
+ }
20
+ /**
21
+ * Input modifiers (like shift, option, command, etc) that change the behaviour
22
+ * of mouse clicks and keyboard presses.
23
+ *
24
+ * @group Recording
25
+ */
26
+ export type InputModifier =
27
+ /**
28
+ * Caps lock key, toggles on/off with a single press, making all input
29
+ * characters capitals.
30
+ *
31
+ * Usually found on the left side of the keyboard, available on all regular
32
+ * keyboards.
33
+ */
34
+ 'capsLock'
35
+ /**
36
+ * Shift key, making input characters capitals as long as it is pressed. Also
37
+ * often involved in hotkeys.
38
+ *
39
+ * Usually found on both the left and right side of the character block on the
40
+ * keyboard, available on all regular keyboards.
41
+ */
42
+ | 'shift'
43
+ /**
44
+ * Control key, often involved in hotkeys.
45
+ *
46
+ * Usually found on both the left side of the character block on the keyboard,
47
+ * available on all regular keyboards.
48
+ */
49
+ | 'control'
50
+ /**
51
+ * Option key, used to type alternative characters. Also often involved in
52
+ * hotkeys.
53
+ *
54
+ * Usually found on both the left and right side of the character block on the
55
+ * keyboard, available on all regular keyboards.
56
+ */
57
+ | 'option'
58
+ /**
59
+ * Command key, often involved in hotkeys.
60
+ *
61
+ * Usually found on both the left and right side of the spacebar, available on
62
+ * all regular keyboards.
63
+ */
64
+ | 'command'
65
+ /**
66
+ * Function (fn) key, used to modify key behaviour of keys with system
67
+ * functionality.
68
+ *
69
+ * For example changing delete into forward delete or re-enabling function
70
+ * key behaviour instead of adjusting system settings like brightness or
71
+ * volume.
72
+ *
73
+ * Usually found on the bottom left of the keyboard or on larger keyboards to
74
+ * left of the numeric keypad, above the arrow keys, available on all regular
75
+ * keyboards.
76
+ */
77
+ | 'function';
78
+ /**
79
+ * Type of keyboard event.
80
+ *
81
+ * Represents the cause that generated a keyboard event.
82
+ *
83
+ * @group Recording
84
+ */
85
+ export type KeyboardEventType =
86
+ /** Key is pressed down. */
87
+ 'down'
88
+ /** Key is released. */
89
+ | 'up';
90
+ /**
91
+ * Type of a keyboard key.
92
+ *
93
+ * Helps make the distinction between a regular character key (like A, 1, /,
94
+ * etc) and special keys (like escape, space, arrow keys, etc) without having to
95
+ * know exact keycodes or unicode characters.
96
+ *
97
+ * - note: Does not include modifier keys (like shift, option, command, etc)
98
+ * since those are supposed to be pressed together they're represented as
99
+ * {@link InputModifier}.
100
+ *
101
+ * @group Recording
102
+ */
103
+ export type KeyboardKeyType =
104
+ /**
105
+ * Character key, any key representing a character (letter or number) that is
106
+ * typed.
107
+ *
108
+ * This indicates the key doesn't represent any special key.
109
+ */
110
+ 'character'
111
+ /**
112
+ * Escape key, exit the current state or abort the current action.
113
+ *
114
+ * Usually found in the top left of the keyboard, available on all regular
115
+ * keyboards.
116
+ */
117
+ | 'escape'
118
+ /**
119
+ * Delete key, also known as backspace. Removes the character left of the
120
+ * caret.
121
+ *
122
+ * Usually found in the top right of the character key block of the keyboard,
123
+ * available on all regular keyboards.
124
+ */
125
+ | 'delete'
126
+ /**
127
+ * Tab key, indent text or move to the next item.
128
+ *
129
+ * Usually found on the left side of the character key block of the keyboard,
130
+ * available on all regular keyboards.
131
+ */
132
+ | 'tab'
133
+ /**
134
+ * Return key, insert newline or confirm action. Also represents the enter key
135
+ * available on some keyboards.
136
+ *
137
+ * Usually found on the right side of the character key block of the keyboard,
138
+ * available on all regular keyboards.
139
+ */
140
+ | 'return'
141
+ /**
142
+ * Spacebar key, insert a space or confirm selection.
143
+ *
144
+ * Usually found on the bottom of the character key block of the keyboard,
145
+ * available on all regular keyboards.
146
+ */
147
+ | 'space'
148
+ /**
149
+ * Left arrow key, moves caret to the left.
150
+ *
151
+ * Usually found in the arrow block in the bottom right of the keyboard, or on
152
+ * larger keyboard in the center of the keyboard, available on all regular
153
+ * keyboards.
154
+ */
155
+ | 'leftArrow'
156
+ /**
157
+ * Right arrow key, moves caret to the right.
158
+ *
159
+ * Usually found in the arrow block in the bottom right of the keyboard, or on
160
+ * larger keyboard in the center of the keyboard, available on all regular
161
+ * keyboards.
162
+ */
163
+ | 'rightArrow'
164
+ /**
165
+ * Down arrow key, moves caret down.
166
+ *
167
+ * Usually found in the arrow block in the bottom right of the keyboard, or on
168
+ * larger keyboard in the center of the keyboard, available on all regular
169
+ * keyboards.
170
+ */
171
+ | 'downArrow'
172
+ /**
173
+ * Up arrow key, moves caret up.
174
+ *
175
+ * Usually found in the arrow block in the bottom right of the keyboard, or on
176
+ * larger keyboard in the center of the keyboard, available on all regular
177
+ * keyboards.
178
+ */
179
+ | 'upArrow'
180
+ /**
181
+ * Delete key, removes the character right of the caret.
182
+ *
183
+ * Usually found in the key block left of the numeric keypad and above the
184
+ * arrows on the Magic Keyboard. Not available as a key on the smaller Magic
185
+ * Keyboard and MacBooks.
186
+ */
187
+ | 'deleteForward'
188
+ /**
189
+ * Home key, scrolls to the very top.
190
+ *
191
+ * Usually found in the key block left of the numeric keypad and above the
192
+ * arrows on the Magic Keyboard. Not available as a key on the smaller Magic
193
+ * Keyboard and MacBooks.
194
+ */
195
+ | 'home'
196
+ /**
197
+ * End key, scrolls to the very bottom.
198
+ *
199
+ * Usually found in the key block left of the numeric keypad and above the
200
+ * arrows on the Magic Keyboard. Not available as a key on the smaller Magic
201
+ * Keyboard and MacBooks.
202
+ */
203
+ | 'end'
204
+ /**
205
+ * Page up key, scrolls one page up.
206
+ *
207
+ * Usually found in the key block left of the numeric keypad and above the
208
+ * arrows on the Magic Keyboard. Not available as a key on the smaller Magic
209
+ * Keyboard and MacBooks.
210
+ */
211
+ | 'pageUp'
212
+ /**
213
+ * Page down key, scroll one page down.
214
+ *
215
+ * Usually found in the key block left of the numeric keypad and above the
216
+ * arrows on the Magic Keyboard. Not available as a key on the smaller Magic
217
+ * Keyboard and MacBooks.
218
+ */
219
+ | 'pageDown'
220
+ /**
221
+ * Clear key, clears the contents of the focused entry field.
222
+ *
223
+ * Usually found on the top left of the numpad on the Apple Magic Keyboard. Not
224
+ * available as a key on the smaller Magic Keyboard and MacBooks.
225
+ */
226
+ | 'clear'
227
+ /**
228
+ * Function key 1, might default to the brightness system function and not be
229
+ * received at all.
230
+ *
231
+ * Usually found in the top row of keys, next to the escape key, available on
232
+ * most keyboards.
233
+ */
234
+ | 'f1'
235
+ /**
236
+ * Function key 2, might default to the brightness system function and not be
237
+ * received at all.
238
+ *
239
+ * Usually found in the top row of keys, available on most keyboards.
240
+ */
241
+ | 'f2'
242
+ /**
243
+ * Function key 3, might default to the mission control system function and
244
+ * not be received at all.
245
+ *
246
+ * Usually found in the top row of keys, available on most keyboards.
247
+ */
248
+ | 'f3'
249
+ /**
250
+ * Function key 4, might default to the search system function and not be
251
+ * received at all.
252
+ *
253
+ * Usually found in the top row of keys, available on most keyboards.
254
+ */
255
+ | 'f4'
256
+ /**
257
+ * Function key 5, might default to the Siri assistant system function and not
258
+ * be received at all.
259
+ *
260
+ * Usually found in the top row of keys, available on most keyboards.
261
+ */
262
+ | 'f5'
263
+ /**
264
+ * Function key 6, might default to the do not disturb system function and not
265
+ * be received at all.
266
+ *
267
+ * Usually found in the top row of keys, available on most keyboards.
268
+ */
269
+ | 'f6'
270
+ /**
271
+ * Function key 7, might default to the media control previous system function
272
+ * and not be received at all.
273
+ *
274
+ * Usually found in the top row of keys, available on most keyboards.
275
+ */
276
+ | 'f7'
277
+ /**
278
+ * Function key 8, might default to the media control play/pause system
279
+ * function and not be received at all.
280
+ *
281
+ * Usually found in the top row of keys, available on most keyboards.
282
+ */
283
+ | 'f8'
284
+ /**
285
+ * Function key 9, might default to the media control next system function and
286
+ * not be received at all.
287
+ *
288
+ * Usually found in the top row of keys, available on most keyboards.
289
+ */
290
+ | 'f9'
291
+ /**
292
+ * Function key 10, might default to the mute volume system function and not
293
+ * be received at all.
294
+ *
295
+ * Usually found in the top row of keys, available on most keyboards.
296
+ */
297
+ | 'f10'
298
+ /**
299
+ * Function key 11, might default to the decrease volume system function and
300
+ * not be received at all.
301
+ *
302
+ * Usually found in the top row of keys, available on most keyboards.
303
+ */
304
+ | 'f11'
305
+ /**
306
+ * Function key 12, might default to the increase volume system function and
307
+ * not be received at all.
308
+ *
309
+ * Usually found in the top row of keys, available on most keyboards.
310
+ */
311
+ | 'f12'
312
+ /**
313
+ * Function key 13, might default to the increase volume system function and
314
+ * not be received at all.
315
+ *
316
+ * Usually found in the top row of keys, available on larger keyboards such as
317
+ * the Magic Keyboard with Numeric Keypad.
318
+ */
319
+ | 'f13'
320
+ /**
321
+ * Function key 14, might default to the increase volume system function and
322
+ * not be received at all.
323
+ *
324
+ * Usually found in the top row of keys, available on older smaller keyboards
325
+ * without TouchID and larger keyboards such as the Magic Keyboard with
326
+ * Numeric Keypad.
327
+ */
328
+ | 'f14'
329
+ /**
330
+ * Function key 15, might default to the increase volume system function and
331
+ * not be received at all.
332
+ *
333
+ * Usually found in the top row of keys, available on larger keyboards such as
334
+ * the Magic Keyboard with Numeric Keypad.
335
+ */
336
+ | 'f15'
337
+ /**
338
+ * Function key 16, might default to the increase volume system function and
339
+ * not be received at all.
340
+ *
341
+ * Usually found in the top row of keys above the numeric keypad, available on
342
+ * larger keyboards such as the Magic Keyboard with Numeric Keypad.
343
+ */
344
+ | 'f16'
345
+ /**
346
+ * Function key 17, might default to the increase volume system function and
347
+ * not be received at all.
348
+ *
349
+ * Usually found in the top row of keys above the numeric keypad, available on
350
+ * larger keyboards such as the Magic Keyboard with Numeric Keypad.
351
+ */
352
+ | 'f17'
353
+ /**
354
+ * Function key 18, might default to the increase volume system function and
355
+ * not be received at all.
356
+ *
357
+ * Usually found in the top row of keys above the numeric keypad, available on
358
+ * larger keyboards such as the Magic Keyboard with Numeric Keypad.
359
+ */
360
+ | 'f18'
361
+ /**
362
+ * Function key 19, might default to the increase volume system function and
363
+ * not be received at all.
364
+ *
365
+ * Usually found in the top row of keys above the numeric keypad, available on
366
+ * larger keyboards such as the Magic Keyboard with Numeric Keypad.
367
+ */
368
+ | 'f19';
369
+ /**
370
+ * Type of mouse event.
371
+ *
372
+ * Represents the cause that generated a mouse event.
373
+ *
374
+ * @group Recording
375
+ */
376
+ export type MouseEventType =
377
+ /** Mouse button is pressed down. */
378
+ 'down'
379
+ /** Mouse button is released. */
380
+ | 'up'
381
+ /** Mouse pointer is moved, without any buttons pressed. */
382
+ | 'moved'
383
+ /** Mouse pointer is moved, with a button pressed. */
384
+ | 'dragged'
385
+ /**
386
+ * Mouse cursor changed shape.
387
+ *
388
+ * The mouse cursor can change shape while the mouse is not used by the user.
389
+ * For example the application the mouse is hovering over can be unresponsive
390
+ * changing the mouse to the beachball, or content can appear like a link that
391
+ * moves under the cursor.
392
+ *
393
+ * This event indicates such a change of cursor shape.
394
+ */
395
+ | 'cursorChanged';
396
+ /**
397
+ * Mouse button types.
398
+ *
399
+ * @group Recording
400
+ */
401
+ export type MouseButton =
402
+ /** The primary mouse button (usually left button). */
403
+ 'primary'
404
+ /** The secondary mouse button (usually right button). */
405
+ | 'secondary'
406
+ /** The center mouse button (usually scroll wheel click). */
407
+ | 'center'
408
+ /** Any other mouse button not covered by the above cases. */
409
+ | 'other';
410
+ /**
411
+ * Mouse cursor types (also called pointer).
412
+ *
413
+ * @group Recording
414
+ */
415
+ export type CursorType =
416
+ /** A custom cursor that is not recognized as a system cursor. */
417
+ 'custom'
418
+ /** The default system cursor, an arrow. */
419
+ | 'arrow'
420
+ /**
421
+ * System cursor that looks like a capital I with a tiny crossbeam at its
422
+ * middle.
423
+ */
424
+ | 'iBeam'
425
+ /** The cross-hair system cursor. */
426
+ | 'crosshair'
427
+ /** The closed-hand system cursor. */
428
+ | 'closedHand'
429
+ /** The open-hand system cursor. */
430
+ | 'openHand'
431
+ /** The pointing-hand system cursor. */
432
+ | 'pointingHand'
433
+ /** The resize-left system cursor. */
434
+ | 'resizeLeft'
435
+ /** The resize-right system cursor. */
436
+ | 'resizeRight'
437
+ /** The resize-left-and-right system cursor. */
438
+ | 'resizeLeftRight'
439
+ /** The resize-up system cursor. */
440
+ | 'resizeUp'
441
+ /** The resize-down system cursor. */
442
+ | 'resizeDown'
443
+ /** The resize-up-and-down system cursor. */
444
+ | 'resizeUpDown'
445
+ /**
446
+ * System cursor indicating that the current operation will result in a
447
+ * disappearing item.
448
+ */
449
+ | 'disappearingItem'
450
+ /** System cursor for editing vertical layout text. */
451
+ | 'iBeamCursorForVerticalLayout'
452
+ /** The operation not allowed system cursor. */
453
+ | 'operationNotAllowed'
454
+ /**
455
+ * System cursor indicating that the current operation will result in a link
456
+ * action.
457
+ */
458
+ | 'dragLink'
459
+ /**
460
+ * System cursor indicating that the current operation will result in a copy
461
+ * action.
462
+ */
463
+ | 'dragCopy'
464
+ /** The contextual menu system cursor. */
465
+ | 'contextualMenu'
466
+ /** The column resize system cursor. Available on macOS 15+. */
467
+ | 'columnResize'
468
+ /** The row resize system cursor. Available on macOS 15+. */
469
+ | 'rowResize'
470
+ /** The zoom in system cursor. Available on macOS 15+. */
471
+ | 'zoomIn'
472
+ /** The zoom out system cursor. Available on macOS 15+. */
473
+ | 'zoomOut'
474
+ /** Private bottom-left resize cursor. */
475
+ | 'bottomLeftResize'
476
+ /** Private bottom-right resize cursor. */
477
+ | 'bottomRightResize'
478
+ /** Private top-left resize cursor. */
479
+ | 'topLeftResize'
480
+ /** Private top-right resize cursor. */
481
+ | 'topRightResize'
482
+ /** Private horizontal resize cursor. */
483
+ | 'horizontalResize'
484
+ /** Private vertical resize cursor. */
485
+ | 'verticalResize'
486
+ /**
487
+ * Private busy but clickable cursor (spinning beachball that's still
488
+ * interactive).
489
+ */
490
+ | 'busyButClickable'
491
+ /** Private generic drag cursor. */
492
+ | 'genericDrag'
493
+ /** Private hand cursor. */
494
+ | 'hand'
495
+ /** Private help cursor. */
496
+ | 'help'
497
+ /** Private override help cursor. */
498
+ | 'overrideHelp'
499
+ /** Private window resize east cursor. */
500
+ | 'windowResizeEast'
501
+ /** Private window resize east-west cursor. */
502
+ | 'windowResizeEastWest'
503
+ /** Private window resize north cursor. */
504
+ | 'windowResizeNorth'
505
+ /** Private window resize north-east cursor. */
506
+ | 'windowResizeNorthEast'
507
+ /** Private window resize north-east-south-west cursor. */
508
+ | 'windowResizeNorthEastSouthWest'
509
+ /** Private window resize north-south cursor. */
510
+ | 'windowResizeNorthSouth'
511
+ /** Private window resize north-west cursor. */
512
+ | 'windowResizeNorthWest'
513
+ /** Private window resize north-west-south-east cursor. */
514
+ | 'windowResizeNorthWestSouthEast'
515
+ /** Private window resize south cursor. */
516
+ | 'windowResizeSouth'
517
+ /** Private window resize south-east cursor. */
518
+ | 'windowResizeSouthEast'
519
+ /** Private window resize south-west cursor. */
520
+ | 'windowResizeSouthWest'
521
+ /** Private window resize west cursor. */
522
+ | 'windowResizeWest';
523
+ /**
524
+ * Mouse movement and clicks.
525
+ *
526
+ * @group Recording
527
+ */
528
+ export interface RecordedMouseEvent {
529
+ /** Discriminator marking this as a mouse event. */
530
+ type: 'mouse';
531
+ /** Type of mouse event this is. */
532
+ mouseEventType: MouseEventType;
533
+ /** Time the event occurred in the recording. */
534
+ time: EventTime;
535
+ /**
536
+ * Input modifier keys (like shift, option, command, etc) pressed during this
537
+ * event.
538
+ *
539
+ * Possible values will appear at most once, no duplicate values will be
540
+ * present.
541
+ */
542
+ modifiers: InputModifier[];
543
+ /**
544
+ * X-axis position of the mouse cursor relative to the top left of recorded
545
+ * area, ranging from 0 to 1.
546
+ */
547
+ x: number;
548
+ /**
549
+ * Y-axis position of the mouse cursor relative to the top left of recorded
550
+ * area, ranging from 0 to 1.
551
+ */
552
+ y: number;
553
+ /** The relevant mouse button involved in this event. */
554
+ button?: MouseButton;
555
+ /** The type of cursor shown during this event. */
556
+ cursorType: CursorType;
557
+ /** Marks a click on the recording app. */
558
+ targetsCurrentProcess: boolean;
559
+ }
560
+ /**
561
+ * Keys pressed and released on the keyboard.
562
+ *
563
+ * - note: Pressing/releasing input modifiers (like shift, option, command, etc)
564
+ * are not captured by this event, but through {@link ModifiersChangedEvent}.
565
+ *
566
+ * @group Recording
567
+ */
568
+ export interface RecordedKeyboardEvent {
569
+ /** Discriminator marking this as a keyboard event. */
570
+ type: 'keyboard';
571
+ /** Type of keyboard event this is. */
572
+ keyboardEventType: KeyboardEventType;
573
+ /** Time the event occurred in the recording. */
574
+ time: EventTime;
575
+ /**
576
+ * Input modifier keys (like shift, option, command, etc) pressed during this
577
+ * event.
578
+ *
579
+ * Possible values will appear at most once, no duplicate values will be
580
+ * present.
581
+ */
582
+ modifiers: InputModifier[];
583
+ /**
584
+ * Classifies the key as a regular character key or one of the recognised
585
+ * special keys (escape, arrows, function keys, etc) without needing to
586
+ * inspect raw keycodes. See {@link KeyboardKeyType}.
587
+ */
588
+ keyType: KeyboardKeyType;
589
+ /**
590
+ * A short human-readable label for the key (e.g. `"esc"`, `"return"`, `"left"`, `"F1"`).
591
+ * Character keys carry the produced character, uppercased (e.g. `"A"`, `"1"`, `"/"`); the
592
+ * placeholder `"□"` is used only as a fallback when the character cannot be determined.
593
+ */
594
+ keyTitle: string;
595
+ /**
596
+ * A single-glyph symbol for the key (e.g. `"⎋"`, `"⏎"`, `"←"`, `"⌫"`). Function keys fall back to
597
+ * their label (`"F1"`); character keys carry the produced character, uppercased, with `"□"` as the
598
+ * fallback when it cannot be determined.
599
+ */
600
+ keySymbol: string;
601
+ /**
602
+ * The character(s) the key press produced, if any.
603
+ *
604
+ * Reflects the actual typed text after applying the active keyboard layout
605
+ * and modifiers (so e.g. shift yields a capital). Absent for keys that don't
606
+ * generate characters.
607
+ */
608
+ characters?: string;
609
+ /**
610
+ * Whether the key event is a repeat.
611
+ *
612
+ * Repeats happen when the user holds the key down for a longer period of time
613
+ * and the system starts repeating the same key press over and over again.
614
+ */
615
+ isARepeat: boolean;
616
+ }
617
+ /**
618
+ * Input modifiers (like shift, option, command, etc) pressed or released.
619
+ *
620
+ * @group Recording
621
+ */
622
+ export interface ModifiersChangedEvent {
623
+ /** Discriminator marking this as a modifiers-changed event. */
624
+ type: 'modifiersChanged';
625
+ /** Time the event occurred in the recording. */
626
+ time: EventTime;
627
+ /**
628
+ * Input modifier keys (like shift, option, command, etc) pressed during this
629
+ * event.
630
+ *
631
+ * Possible values will appear at most once, no duplicate values will be
632
+ * present.
633
+ */
634
+ modifiers: InputModifier[];
635
+ }
636
+ /**
637
+ * Event during input recording where the earlier and later events are no longer
638
+ * continuous, e.g. after a pause/resume.
639
+ *
640
+ * @group Recording
641
+ */
642
+ export interface DiscontinuationEvent {
643
+ /** Discriminator marking this as a discontinuation event. */
644
+ type: 'discontinuation';
645
+ /** Time the event occurred in the recording. */
646
+ time: EventTime;
647
+ }
648
+ /**
649
+ * A single input event recorded during a RecordKit recording.
650
+ *
651
+ * Discriminated union on the `type` field. The payload properties of each
652
+ * member are flattened alongside the `type` discriminator in the encoded JSON.
653
+ *
654
+ * @remarks
655
+ * Every member carries a {@link EventTime} `time` field. The mouse, keyboard
656
+ * and modifiers-changed members also carry a `modifiers` set; the
657
+ * discontinuation member has no modifiers (treat it as empty).
658
+ *
659
+ * @group Recording
660
+ */
661
+ export type RecordedInputEvent = RecordedMouseEvent | RecordedKeyboardEvent | ModifiersChangedEvent | DiscontinuationEvent;
@@ -0,0 +1,8 @@
1
+ // Type definitions mirroring the JSON written to the input-events sidecar file inside a RecordKit
2
+ // recording bundle. RecordKit records mouse, keyboard, modifier-change and discontinuation events
3
+ // during a recording; they are serialized as JSON to a sidecar file in the bundle. These types
4
+ // mirror the Swift `Codable` types in `RKInputEvent.swift` exactly, so consumers can parse those
5
+ // JSON files type-safely. Each top-level event encodes as a flat object with a `"type"` discriminator
6
+ // at the same level as its payload properties (not nested). Types only — no runtime code in this module.
7
+ export {};
8
+ //# sourceMappingURL=InputEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputEvents.js","sourceRoot":"","sources":["../src/InputEvents.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,iGAAiG;AACjG,sGAAsG;AACtG,yGAAyG"}
@@ -19,6 +19,16 @@ export class IpcRecordKit {
19
19
  childProcess.on('exit', (code, signal) => { console.error(`RecordKit: [RPC] Exited with code ${code} and signal ${signal}`); });
20
20
  childProcess.on('spawn', () => { resolve(childProcess); });
21
21
  });
22
+ this.childProcess.on('close', (code, signal) => {
23
+ // No response can arrive anymore; fail all in-flight and future requests instead of letting
24
+ // them hang forever.
25
+ this.nsrpc.terminate(new Error(`RecordKit: [RPC] Process is gone (closed with code ${code} and signal ${signal}).`));
26
+ });
27
+ this.childProcess.stdin?.on('error', (error) => {
28
+ // Without an error listener, a failed write to a dead process would crash Node with an
29
+ // unhandled 'error' event. The 'close' handler above already fails all requests.
30
+ console.error(`RecordKit: [RPC] !! Failed to write to RPC process: ${error}`);
31
+ });
22
32
  const { stdout, stderr } = this.childProcess;
23
33
  if (!stdout) {
24
34
  throw new Error('RecordKit: [RPC] !! No stdout stream on child process.');
@@ -37,6 +47,9 @@ export class IpcRecordKit {
37
47
  if (!stdin) {
38
48
  throw new Error('RecordKit: [RPC] !! Missing stdin stream.');
39
49
  }
50
+ if (stdin.destroyed) {
51
+ throw new Error('RecordKit: [RPC] !! Process is gone, cannot write to its stdin.');
52
+ }
40
53
  stdin.write(message + "\n");
41
54
  }
42
55
  }