@rpascene/shared 0.30.8

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 (177) hide show
  1. package/README.md +9 -0
  2. package/dist/es/baseDB.mjs +109 -0
  3. package/dist/es/build/copy-static.mjs +29 -0
  4. package/dist/es/common.mjs +37 -0
  5. package/dist/es/constants/example-code.mjs +202 -0
  6. package/dist/es/constants/index.mjs +74 -0
  7. package/dist/es/env/basic.mjs +6 -0
  8. package/dist/es/env/constants.mjs +97 -0
  9. package/dist/es/env/decide-model-config.mjs +172 -0
  10. package/dist/es/env/global-config-manager.mjs +82 -0
  11. package/dist/es/env/helper.mjs +45 -0
  12. package/dist/es/env/index.mjs +5 -0
  13. package/dist/es/env/init-debug.mjs +18 -0
  14. package/dist/es/env/model-config-manager.mjs +99 -0
  15. package/dist/es/env/parse.mjs +69 -0
  16. package/dist/es/env/types.mjs +265 -0
  17. package/dist/es/env/utils.mjs +18 -0
  18. package/dist/es/extractor/constants.mjs +2 -0
  19. package/dist/es/extractor/cs_postmessage.mjs +61 -0
  20. package/dist/es/extractor/customLocator.mjs +646 -0
  21. package/dist/es/extractor/debug.mjs +6 -0
  22. package/dist/es/extractor/dom-util.mjs +92 -0
  23. package/dist/es/extractor/index.mjs +7 -0
  24. package/dist/es/extractor/locator.mjs +95 -0
  25. package/dist/es/extractor/tree.mjs +81 -0
  26. package/dist/es/extractor/util.mjs +244 -0
  27. package/dist/es/extractor/web-extractor.mjs +361 -0
  28. package/dist/es/img/box-select.mjs +184 -0
  29. package/dist/es/img/draw-box.mjs +42 -0
  30. package/dist/es/img/get-jimp.mjs +10 -0
  31. package/dist/es/img/get-photon.mjs +19 -0
  32. package/dist/es/img/get-sharp.mjs +11 -0
  33. package/dist/es/img/index.mjs +5 -0
  34. package/dist/es/img/info.mjs +32 -0
  35. package/dist/es/img/transform.mjs +192 -0
  36. package/dist/es/index.mjs +3 -0
  37. package/dist/es/logger.mjs +61 -0
  38. package/dist/es/node/fs.mjs +44 -0
  39. package/dist/es/node/index.mjs +1 -0
  40. package/dist/es/polyfills/async-hooks.mjs +2 -0
  41. package/dist/es/polyfills/index.mjs +1 -0
  42. package/dist/es/types/index.mjs +3 -0
  43. package/dist/es/us-keyboard-layout.mjs +1414 -0
  44. package/dist/es/us-keyboard-layout.mjs.LICENSE.txt +5 -0
  45. package/dist/es/utils.mjs +66 -0
  46. package/dist/lib/baseDB.js +149 -0
  47. package/dist/lib/build/copy-static.js +77 -0
  48. package/dist/lib/common.js +93 -0
  49. package/dist/lib/constants/example-code.js +239 -0
  50. package/dist/lib/constants/index.js +153 -0
  51. package/dist/lib/env/basic.js +40 -0
  52. package/dist/lib/env/constants.js +143 -0
  53. package/dist/lib/env/decide-model-config.js +212 -0
  54. package/dist/lib/env/global-config-manager.js +116 -0
  55. package/dist/lib/env/helper.js +85 -0
  56. package/dist/lib/env/index.js +94 -0
  57. package/dist/lib/env/init-debug.js +52 -0
  58. package/dist/lib/env/model-config-manager.js +133 -0
  59. package/dist/lib/env/parse.js +106 -0
  60. package/dist/lib/env/types.js +650 -0
  61. package/dist/lib/env/utils.js +61 -0
  62. package/dist/lib/extractor/constants.js +42 -0
  63. package/dist/lib/extractor/cs_postmessage.js +98 -0
  64. package/dist/lib/extractor/customLocator.js +698 -0
  65. package/dist/lib/extractor/debug.js +12 -0
  66. package/dist/lib/extractor/dom-util.js +150 -0
  67. package/dist/lib/extractor/index.js +153 -0
  68. package/dist/lib/extractor/locator.js +141 -0
  69. package/dist/lib/extractor/tree.js +127 -0
  70. package/dist/lib/extractor/util.js +335 -0
  71. package/dist/lib/extractor/web-extractor.js +407 -0
  72. package/dist/lib/img/box-select.js +232 -0
  73. package/dist/lib/img/draw-box.js +89 -0
  74. package/dist/lib/img/get-jimp.js +72 -0
  75. package/dist/lib/img/get-photon.js +76 -0
  76. package/dist/lib/img/get-sharp.js +63 -0
  77. package/dist/lib/img/index.js +102 -0
  78. package/dist/lib/img/info.js +86 -0
  79. package/dist/lib/img/transform.js +279 -0
  80. package/dist/lib/index.js +43 -0
  81. package/dist/lib/logger.js +114 -0
  82. package/dist/lib/node/fs.js +97 -0
  83. package/dist/lib/node/index.js +60 -0
  84. package/dist/lib/polyfills/async-hooks.js +36 -0
  85. package/dist/lib/polyfills/index.js +60 -0
  86. package/dist/lib/types/index.js +37 -0
  87. package/dist/lib/us-keyboard-layout.js +1457 -0
  88. package/dist/lib/us-keyboard-layout.js.LICENSE.txt +5 -0
  89. package/dist/lib/utils.js +136 -0
  90. package/dist/types/baseDB.d.ts +25 -0
  91. package/dist/types/build/copy-static.d.ts +31 -0
  92. package/dist/types/common.d.ts +12 -0
  93. package/dist/types/constants/example-code.d.ts +2 -0
  94. package/dist/types/constants/index.d.ts +23 -0
  95. package/dist/types/env/basic.d.ts +6 -0
  96. package/dist/types/env/constants.d.ts +40 -0
  97. package/dist/types/env/decide-model-config.d.ts +14 -0
  98. package/dist/types/env/global-config-manager.d.ts +32 -0
  99. package/dist/types/env/helper.d.ts +6 -0
  100. package/dist/types/env/index.d.ts +4 -0
  101. package/dist/types/env/init-debug.d.ts +1 -0
  102. package/dist/types/env/model-config-manager.d.ts +24 -0
  103. package/dist/types/env/parse.d.ts +12 -0
  104. package/dist/types/env/types.d.ts +295 -0
  105. package/dist/types/env/utils.d.ts +7 -0
  106. package/dist/types/extractor/constants.d.ts +1 -0
  107. package/dist/types/extractor/cs_postmessage.d.ts +2 -0
  108. package/dist/types/extractor/customLocator.d.ts +69 -0
  109. package/dist/types/extractor/debug.d.ts +1 -0
  110. package/dist/types/extractor/dom-util.d.ts +26 -0
  111. package/dist/types/extractor/index.d.ts +36 -0
  112. package/dist/types/extractor/locator.d.ts +7 -0
  113. package/dist/types/extractor/tree.d.ts +9 -0
  114. package/dist/types/extractor/util.d.ts +43 -0
  115. package/dist/types/extractor/web-extractor.d.ts +19 -0
  116. package/dist/types/img/box-select.d.ts +25 -0
  117. package/dist/types/img/draw-box.d.ts +15 -0
  118. package/dist/types/img/get-jimp.d.ts +2 -0
  119. package/dist/types/img/get-photon.d.ts +8 -0
  120. package/dist/types/img/get-sharp.d.ts +3 -0
  121. package/dist/types/img/index.d.ts +4 -0
  122. package/dist/types/img/info.d.ts +29 -0
  123. package/dist/types/img/transform.d.ts +88 -0
  124. package/dist/types/index.d.ts +3 -0
  125. package/dist/types/logger.d.ts +4 -0
  126. package/dist/types/node/fs.d.ts +15 -0
  127. package/dist/types/node/index.d.ts +1 -0
  128. package/dist/types/polyfills/async-hooks.d.ts +6 -0
  129. package/dist/types/polyfills/index.d.ts +4 -0
  130. package/dist/types/types/index.d.ts +37 -0
  131. package/dist/types/us-keyboard-layout.d.ts +32 -0
  132. package/dist/types/utils.d.ts +22 -0
  133. package/package.json +102 -0
  134. package/src/baseDB.ts +158 -0
  135. package/src/build/copy-static.ts +62 -0
  136. package/src/common.ts +67 -0
  137. package/src/constants/example-code.ts +202 -0
  138. package/src/constants/index.ts +81 -0
  139. package/src/env/basic.ts +12 -0
  140. package/src/env/constants.ts +291 -0
  141. package/src/env/decide-model-config.ts +319 -0
  142. package/src/env/global-config-manager.ts +174 -0
  143. package/src/env/helper.ts +80 -0
  144. package/src/env/index.ts +4 -0
  145. package/src/env/init-debug.ts +29 -0
  146. package/src/env/model-config-manager.ts +145 -0
  147. package/src/env/parse.ts +131 -0
  148. package/src/env/types.ts +573 -0
  149. package/src/env/utils.ts +39 -0
  150. package/src/extractor/constants.ts +5 -0
  151. package/src/extractor/cs_postmessage.ts +101 -0
  152. package/src/extractor/customLocator.ts +1138 -0
  153. package/src/extractor/debug.ts +10 -0
  154. package/src/extractor/dom-util.ts +141 -0
  155. package/src/extractor/index.ts +54 -0
  156. package/src/extractor/locator.ts +179 -0
  157. package/src/extractor/tree.ts +179 -0
  158. package/src/extractor/util.ts +468 -0
  159. package/src/extractor/web-extractor.ts +559 -0
  160. package/src/img/box-select.ts +346 -0
  161. package/src/img/draw-box.ts +60 -0
  162. package/src/img/get-jimp.ts +12 -0
  163. package/src/img/get-photon.ts +48 -0
  164. package/src/img/get-sharp.ts +18 -0
  165. package/src/img/index.ts +24 -0
  166. package/src/img/info.ts +79 -0
  167. package/src/img/jimp.d.ts +4 -0
  168. package/src/img/transform.ts +396 -0
  169. package/src/index.ts +6 -0
  170. package/src/logger.ts +93 -0
  171. package/src/node/fs.ts +84 -0
  172. package/src/node/index.ts +1 -0
  173. package/src/polyfills/async-hooks.ts +6 -0
  174. package/src/polyfills/index.ts +4 -0
  175. package/src/types/index.ts +53 -0
  176. package/src/us-keyboard-layout.ts +723 -0
  177. package/src/utils.ts +127 -0
@@ -0,0 +1,723 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export interface KeyDefinition {
11
+ keyCode?: number;
12
+ shiftKeyCode?: number;
13
+ key?: string;
14
+ shiftKey?: string;
15
+ code?: string;
16
+ text?: string;
17
+ shiftText?: string;
18
+ location?: number;
19
+ }
20
+
21
+ /**
22
+ * All the valid keys that can be passed to functions that take user input, such
23
+ * as {@link Keyboard.press | keyboard.press }
24
+ *
25
+ * @public
26
+ */
27
+ export type KeyInput =
28
+ | '0'
29
+ | '1'
30
+ | '2'
31
+ | '3'
32
+ | '4'
33
+ | '5'
34
+ | '6'
35
+ | '7'
36
+ | '8'
37
+ | '9'
38
+ | 'Power'
39
+ | 'Eject'
40
+ | 'Abort'
41
+ | 'Help'
42
+ | 'Backspace'
43
+ | 'Tab'
44
+ | 'Numpad5'
45
+ | 'NumpadEnter'
46
+ | 'Enter'
47
+ | '\r'
48
+ | '\n'
49
+ | 'ShiftLeft'
50
+ | 'ShiftRight'
51
+ | 'ControlLeft'
52
+ | 'ControlRight'
53
+ | 'AltLeft'
54
+ | 'AltRight'
55
+ | 'Pause'
56
+ | 'CapsLock'
57
+ | 'Escape'
58
+ | 'Convert'
59
+ | 'NonConvert'
60
+ | 'Space'
61
+ | 'Numpad9'
62
+ | 'PageUp'
63
+ | 'Numpad3'
64
+ | 'PageDown'
65
+ | 'End'
66
+ | 'Numpad1'
67
+ | 'Home'
68
+ | 'Numpad7'
69
+ | 'ArrowLeft'
70
+ | 'Numpad4'
71
+ | 'Numpad8'
72
+ | 'ArrowUp'
73
+ | 'ArrowRight'
74
+ | 'Numpad6'
75
+ | 'Numpad2'
76
+ | 'ArrowDown'
77
+ | 'Select'
78
+ | 'Open'
79
+ | 'PrintScreen'
80
+ | 'Insert'
81
+ | 'Numpad0'
82
+ | 'Delete'
83
+ | 'NumpadDecimal'
84
+ | 'Digit0'
85
+ | 'Digit1'
86
+ | 'Digit2'
87
+ | 'Digit3'
88
+ | 'Digit4'
89
+ | 'Digit5'
90
+ | 'Digit6'
91
+ | 'Digit7'
92
+ | 'Digit8'
93
+ | 'Digit9'
94
+ | 'KeyA'
95
+ | 'KeyB'
96
+ | 'KeyC'
97
+ | 'KeyD'
98
+ | 'KeyE'
99
+ | 'KeyF'
100
+ | 'KeyG'
101
+ | 'KeyH'
102
+ | 'KeyI'
103
+ | 'KeyJ'
104
+ | 'KeyK'
105
+ | 'KeyL'
106
+ | 'KeyM'
107
+ | 'KeyN'
108
+ | 'KeyO'
109
+ | 'KeyP'
110
+ | 'KeyQ'
111
+ | 'KeyR'
112
+ | 'KeyS'
113
+ | 'KeyT'
114
+ | 'KeyU'
115
+ | 'KeyV'
116
+ | 'KeyW'
117
+ | 'KeyX'
118
+ | 'KeyY'
119
+ | 'KeyZ'
120
+ | 'MetaLeft'
121
+ | 'MetaRight'
122
+ | 'ContextMenu'
123
+ | 'NumpadMultiply'
124
+ | 'NumpadAdd'
125
+ | 'NumpadSubtract'
126
+ | 'NumpadDivide'
127
+ | 'F1'
128
+ | 'F2'
129
+ | 'F3'
130
+ | 'F4'
131
+ | 'F5'
132
+ | 'F6'
133
+ | 'F7'
134
+ | 'F8'
135
+ | 'F9'
136
+ | 'F10'
137
+ | 'F11'
138
+ | 'F12'
139
+ | 'F13'
140
+ | 'F14'
141
+ | 'F15'
142
+ | 'F16'
143
+ | 'F17'
144
+ | 'F18'
145
+ | 'F19'
146
+ | 'F20'
147
+ | 'F21'
148
+ | 'F22'
149
+ | 'F23'
150
+ | 'F24'
151
+ | 'NumLock'
152
+ | 'ScrollLock'
153
+ | 'AudioVolumeMute'
154
+ | 'AudioVolumeDown'
155
+ | 'AudioVolumeUp'
156
+ | 'MediaTrackNext'
157
+ | 'MediaTrackPrevious'
158
+ | 'MediaStop'
159
+ | 'MediaPlayPause'
160
+ | 'Semicolon'
161
+ | 'Equal'
162
+ | 'NumpadEqual'
163
+ | 'Comma'
164
+ | 'Minus'
165
+ | 'Period'
166
+ | 'Slash'
167
+ | 'Backquote'
168
+ | 'BracketLeft'
169
+ | 'Backslash'
170
+ | 'BracketRight'
171
+ | 'Quote'
172
+ | 'AltGraph'
173
+ | 'Props'
174
+ | 'Cancel'
175
+ | 'Clear'
176
+ | 'Shift'
177
+ | 'Control'
178
+ | 'Alt'
179
+ | 'Accept'
180
+ | 'ModeChange'
181
+ | ' '
182
+ | 'Print'
183
+ | 'Execute'
184
+ | '\u0000'
185
+ | 'a'
186
+ | 'b'
187
+ | 'c'
188
+ | 'd'
189
+ | 'e'
190
+ | 'f'
191
+ | 'g'
192
+ | 'h'
193
+ | 'i'
194
+ | 'j'
195
+ | 'k'
196
+ | 'l'
197
+ | 'm'
198
+ | 'n'
199
+ | 'o'
200
+ | 'p'
201
+ | 'q'
202
+ | 'r'
203
+ | 's'
204
+ | 't'
205
+ | 'u'
206
+ | 'v'
207
+ | 'w'
208
+ | 'x'
209
+ | 'y'
210
+ | 'z'
211
+ | 'Meta'
212
+ | '*'
213
+ | '+'
214
+ | '-'
215
+ | '/'
216
+ | ';'
217
+ | '='
218
+ | ','
219
+ | '.'
220
+ | '`'
221
+ | '['
222
+ | '\\'
223
+ | ']'
224
+ | "'"
225
+ | 'Attn'
226
+ | 'CrSel'
227
+ | 'ExSel'
228
+ | 'EraseEof'
229
+ | 'Play'
230
+ | 'ZoomOut'
231
+ | ')'
232
+ | '!'
233
+ | '@'
234
+ | '#'
235
+ | '$'
236
+ | '%'
237
+ | '^'
238
+ | '&'
239
+ | '('
240
+ | 'A'
241
+ | 'B'
242
+ | 'C'
243
+ | 'D'
244
+ | 'E'
245
+ | 'F'
246
+ | 'G'
247
+ | 'H'
248
+ | 'I'
249
+ | 'J'
250
+ | 'K'
251
+ | 'L'
252
+ | 'M'
253
+ | 'N'
254
+ | 'O'
255
+ | 'P'
256
+ | 'Q'
257
+ | 'R'
258
+ | 'S'
259
+ | 'T'
260
+ | 'U'
261
+ | 'V'
262
+ | 'W'
263
+ | 'X'
264
+ | 'Y'
265
+ | 'Z'
266
+ | ':'
267
+ | '<'
268
+ | '_'
269
+ | '>'
270
+ | '?'
271
+ | '~'
272
+ | '{'
273
+ | '|'
274
+ | '}'
275
+ | '"'
276
+ | 'SoftLeft'
277
+ | 'SoftRight'
278
+ | 'Camera'
279
+ | 'Call'
280
+ | 'EndCall'
281
+ | 'VolumeDown'
282
+ | 'VolumeUp';
283
+
284
+ /**
285
+ * @internal
286
+ */
287
+ export const _keyDefinitions: Readonly<Record<KeyInput, KeyDefinition>> = {
288
+ '0': { keyCode: 48, key: '0', code: 'Digit0' },
289
+ '1': { keyCode: 49, key: '1', code: 'Digit1' },
290
+ '2': { keyCode: 50, key: '2', code: 'Digit2' },
291
+ '3': { keyCode: 51, key: '3', code: 'Digit3' },
292
+ '4': { keyCode: 52, key: '4', code: 'Digit4' },
293
+ '5': { keyCode: 53, key: '5', code: 'Digit5' },
294
+ '6': { keyCode: 54, key: '6', code: 'Digit6' },
295
+ '7': { keyCode: 55, key: '7', code: 'Digit7' },
296
+ '8': { keyCode: 56, key: '8', code: 'Digit8' },
297
+ '9': { keyCode: 57, key: '9', code: 'Digit9' },
298
+ Power: { key: 'Power', code: 'Power' },
299
+ Eject: { key: 'Eject', code: 'Eject' },
300
+ Abort: { keyCode: 3, code: 'Abort', key: 'Cancel' },
301
+ Help: { keyCode: 6, code: 'Help', key: 'Help' },
302
+ Backspace: { keyCode: 8, code: 'Backspace', key: 'Backspace' },
303
+ Tab: { keyCode: 9, code: 'Tab', key: 'Tab' },
304
+ Numpad5: {
305
+ keyCode: 12,
306
+ shiftKeyCode: 101,
307
+ key: 'Clear',
308
+ code: 'Numpad5',
309
+ shiftKey: '5',
310
+ location: 3,
311
+ },
312
+ NumpadEnter: {
313
+ keyCode: 13,
314
+ code: 'NumpadEnter',
315
+ key: 'Enter',
316
+ text: '\r',
317
+ location: 3,
318
+ },
319
+ Enter: { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
320
+ '\r': { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
321
+ '\n': { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
322
+ ShiftLeft: { keyCode: 16, code: 'ShiftLeft', key: 'Shift', location: 1 },
323
+ ShiftRight: { keyCode: 16, code: 'ShiftRight', key: 'Shift', location: 2 },
324
+ ControlLeft: {
325
+ keyCode: 17,
326
+ code: 'ControlLeft',
327
+ key: 'Control',
328
+ location: 1,
329
+ },
330
+ ControlRight: {
331
+ keyCode: 17,
332
+ code: 'ControlRight',
333
+ key: 'Control',
334
+ location: 2,
335
+ },
336
+ AltLeft: { keyCode: 18, code: 'AltLeft', key: 'Alt', location: 1 },
337
+ AltRight: { keyCode: 18, code: 'AltRight', key: 'Alt', location: 2 },
338
+ Pause: { keyCode: 19, code: 'Pause', key: 'Pause' },
339
+ CapsLock: { keyCode: 20, code: 'CapsLock', key: 'CapsLock' },
340
+ Escape: { keyCode: 27, code: 'Escape', key: 'Escape' },
341
+ Convert: { keyCode: 28, code: 'Convert', key: 'Convert' },
342
+ NonConvert: { keyCode: 29, code: 'NonConvert', key: 'NonConvert' },
343
+ Space: { keyCode: 32, code: 'Space', key: ' ' },
344
+ Numpad9: {
345
+ keyCode: 33,
346
+ shiftKeyCode: 105,
347
+ key: 'PageUp',
348
+ code: 'Numpad9',
349
+ shiftKey: '9',
350
+ location: 3,
351
+ },
352
+ PageUp: { keyCode: 33, code: 'PageUp', key: 'PageUp' },
353
+ Numpad3: {
354
+ keyCode: 34,
355
+ shiftKeyCode: 99,
356
+ key: 'PageDown',
357
+ code: 'Numpad3',
358
+ shiftKey: '3',
359
+ location: 3,
360
+ },
361
+ PageDown: { keyCode: 34, code: 'PageDown', key: 'PageDown' },
362
+ End: { keyCode: 35, code: 'End', key: 'End' },
363
+ Numpad1: {
364
+ keyCode: 35,
365
+ shiftKeyCode: 97,
366
+ key: 'End',
367
+ code: 'Numpad1',
368
+ shiftKey: '1',
369
+ location: 3,
370
+ },
371
+ Home: { keyCode: 36, code: 'Home', key: 'Home' },
372
+ Numpad7: {
373
+ keyCode: 36,
374
+ shiftKeyCode: 103,
375
+ key: 'Home',
376
+ code: 'Numpad7',
377
+ shiftKey: '7',
378
+ location: 3,
379
+ },
380
+ ArrowLeft: { keyCode: 37, code: 'ArrowLeft', key: 'ArrowLeft' },
381
+ Numpad4: {
382
+ keyCode: 37,
383
+ shiftKeyCode: 100,
384
+ key: 'ArrowLeft',
385
+ code: 'Numpad4',
386
+ shiftKey: '4',
387
+ location: 3,
388
+ },
389
+ Numpad8: {
390
+ keyCode: 38,
391
+ shiftKeyCode: 104,
392
+ key: 'ArrowUp',
393
+ code: 'Numpad8',
394
+ shiftKey: '8',
395
+ location: 3,
396
+ },
397
+ ArrowUp: { keyCode: 38, code: 'ArrowUp', key: 'ArrowUp' },
398
+ ArrowRight: { keyCode: 39, code: 'ArrowRight', key: 'ArrowRight' },
399
+ Numpad6: {
400
+ keyCode: 39,
401
+ shiftKeyCode: 102,
402
+ key: 'ArrowRight',
403
+ code: 'Numpad6',
404
+ shiftKey: '6',
405
+ location: 3,
406
+ },
407
+ Numpad2: {
408
+ keyCode: 40,
409
+ shiftKeyCode: 98,
410
+ key: 'ArrowDown',
411
+ code: 'Numpad2',
412
+ shiftKey: '2',
413
+ location: 3,
414
+ },
415
+ ArrowDown: { keyCode: 40, code: 'ArrowDown', key: 'ArrowDown' },
416
+ Select: { keyCode: 41, code: 'Select', key: 'Select' },
417
+ Open: { keyCode: 43, code: 'Open', key: 'Execute' },
418
+ PrintScreen: { keyCode: 44, code: 'PrintScreen', key: 'PrintScreen' },
419
+ Insert: { keyCode: 45, code: 'Insert', key: 'Insert' },
420
+ Numpad0: {
421
+ keyCode: 45,
422
+ shiftKeyCode: 96,
423
+ key: 'Insert',
424
+ code: 'Numpad0',
425
+ shiftKey: '0',
426
+ location: 3,
427
+ },
428
+ Delete: { keyCode: 46, code: 'Delete', key: 'Delete' },
429
+ NumpadDecimal: {
430
+ keyCode: 46,
431
+ shiftKeyCode: 110,
432
+ code: 'NumpadDecimal',
433
+ key: '\u0000',
434
+ shiftKey: '.',
435
+ location: 3,
436
+ },
437
+ Digit0: { keyCode: 48, code: 'Digit0', shiftKey: ')', key: '0' },
438
+ Digit1: { keyCode: 49, code: 'Digit1', shiftKey: '!', key: '1' },
439
+ Digit2: { keyCode: 50, code: 'Digit2', shiftKey: '@', key: '2' },
440
+ Digit3: { keyCode: 51, code: 'Digit3', shiftKey: '#', key: '3' },
441
+ Digit4: { keyCode: 52, code: 'Digit4', shiftKey: '$', key: '4' },
442
+ Digit5: { keyCode: 53, code: 'Digit5', shiftKey: '%', key: '5' },
443
+ Digit6: { keyCode: 54, code: 'Digit6', shiftKey: '^', key: '6' },
444
+ Digit7: { keyCode: 55, code: 'Digit7', shiftKey: '&', key: '7' },
445
+ Digit8: { keyCode: 56, code: 'Digit8', shiftKey: '*', key: '8' },
446
+ Digit9: { keyCode: 57, code: 'Digit9', shiftKey: '(', key: '9' },
447
+ KeyA: { keyCode: 65, code: 'KeyA', shiftKey: 'A', key: 'a' },
448
+ KeyB: { keyCode: 66, code: 'KeyB', shiftKey: 'B', key: 'b' },
449
+ KeyC: { keyCode: 67, code: 'KeyC', shiftKey: 'C', key: 'c' },
450
+ KeyD: { keyCode: 68, code: 'KeyD', shiftKey: 'D', key: 'd' },
451
+ KeyE: { keyCode: 69, code: 'KeyE', shiftKey: 'E', key: 'e' },
452
+ KeyF: { keyCode: 70, code: 'KeyF', shiftKey: 'F', key: 'f' },
453
+ KeyG: { keyCode: 71, code: 'KeyG', shiftKey: 'G', key: 'g' },
454
+ KeyH: { keyCode: 72, code: 'KeyH', shiftKey: 'H', key: 'h' },
455
+ KeyI: { keyCode: 73, code: 'KeyI', shiftKey: 'I', key: 'i' },
456
+ KeyJ: { keyCode: 74, code: 'KeyJ', shiftKey: 'J', key: 'j' },
457
+ KeyK: { keyCode: 75, code: 'KeyK', shiftKey: 'K', key: 'k' },
458
+ KeyL: { keyCode: 76, code: 'KeyL', shiftKey: 'L', key: 'l' },
459
+ KeyM: { keyCode: 77, code: 'KeyM', shiftKey: 'M', key: 'm' },
460
+ KeyN: { keyCode: 78, code: 'KeyN', shiftKey: 'N', key: 'n' },
461
+ KeyO: { keyCode: 79, code: 'KeyO', shiftKey: 'O', key: 'o' },
462
+ KeyP: { keyCode: 80, code: 'KeyP', shiftKey: 'P', key: 'p' },
463
+ KeyQ: { keyCode: 81, code: 'KeyQ', shiftKey: 'Q', key: 'q' },
464
+ KeyR: { keyCode: 82, code: 'KeyR', shiftKey: 'R', key: 'r' },
465
+ KeyS: { keyCode: 83, code: 'KeyS', shiftKey: 'S', key: 's' },
466
+ KeyT: { keyCode: 84, code: 'KeyT', shiftKey: 'T', key: 't' },
467
+ KeyU: { keyCode: 85, code: 'KeyU', shiftKey: 'U', key: 'u' },
468
+ KeyV: { keyCode: 86, code: 'KeyV', shiftKey: 'V', key: 'v' },
469
+ KeyW: { keyCode: 87, code: 'KeyW', shiftKey: 'W', key: 'w' },
470
+ KeyX: { keyCode: 88, code: 'KeyX', shiftKey: 'X', key: 'x' },
471
+ KeyY: { keyCode: 89, code: 'KeyY', shiftKey: 'Y', key: 'y' },
472
+ KeyZ: { keyCode: 90, code: 'KeyZ', shiftKey: 'Z', key: 'z' },
473
+ MetaLeft: { keyCode: 91, code: 'MetaLeft', key: 'Meta', location: 1 },
474
+ MetaRight: { keyCode: 92, code: 'MetaRight', key: 'Meta', location: 2 },
475
+ ContextMenu: { keyCode: 93, code: 'ContextMenu', key: 'ContextMenu' },
476
+ NumpadMultiply: {
477
+ keyCode: 106,
478
+ code: 'NumpadMultiply',
479
+ key: '*',
480
+ location: 3,
481
+ },
482
+ NumpadAdd: { keyCode: 107, code: 'NumpadAdd', key: '+', location: 3 },
483
+ NumpadSubtract: {
484
+ keyCode: 109,
485
+ code: 'NumpadSubtract',
486
+ key: '-',
487
+ location: 3,
488
+ },
489
+ NumpadDivide: { keyCode: 111, code: 'NumpadDivide', key: '/', location: 3 },
490
+ F1: { keyCode: 112, code: 'F1', key: 'F1' },
491
+ F2: { keyCode: 113, code: 'F2', key: 'F2' },
492
+ F3: { keyCode: 114, code: 'F3', key: 'F3' },
493
+ F4: { keyCode: 115, code: 'F4', key: 'F4' },
494
+ F5: { keyCode: 116, code: 'F5', key: 'F5' },
495
+ F6: { keyCode: 117, code: 'F6', key: 'F6' },
496
+ F7: { keyCode: 118, code: 'F7', key: 'F7' },
497
+ F8: { keyCode: 119, code: 'F8', key: 'F8' },
498
+ F9: { keyCode: 120, code: 'F9', key: 'F9' },
499
+ F10: { keyCode: 121, code: 'F10', key: 'F10' },
500
+ F11: { keyCode: 122, code: 'F11', key: 'F11' },
501
+ F12: { keyCode: 123, code: 'F12', key: 'F12' },
502
+ F13: { keyCode: 124, code: 'F13', key: 'F13' },
503
+ F14: { keyCode: 125, code: 'F14', key: 'F14' },
504
+ F15: { keyCode: 126, code: 'F15', key: 'F15' },
505
+ F16: { keyCode: 127, code: 'F16', key: 'F16' },
506
+ F17: { keyCode: 128, code: 'F17', key: 'F17' },
507
+ F18: { keyCode: 129, code: 'F18', key: 'F18' },
508
+ F19: { keyCode: 130, code: 'F19', key: 'F19' },
509
+ F20: { keyCode: 131, code: 'F20', key: 'F20' },
510
+ F21: { keyCode: 132, code: 'F21', key: 'F21' },
511
+ F22: { keyCode: 133, code: 'F22', key: 'F22' },
512
+ F23: { keyCode: 134, code: 'F23', key: 'F23' },
513
+ F24: { keyCode: 135, code: 'F24', key: 'F24' },
514
+ NumLock: { keyCode: 144, code: 'NumLock', key: 'NumLock' },
515
+ ScrollLock: { keyCode: 145, code: 'ScrollLock', key: 'ScrollLock' },
516
+ AudioVolumeMute: {
517
+ keyCode: 173,
518
+ code: 'AudioVolumeMute',
519
+ key: 'AudioVolumeMute',
520
+ },
521
+ AudioVolumeDown: {
522
+ keyCode: 174,
523
+ code: 'AudioVolumeDown',
524
+ key: 'AudioVolumeDown',
525
+ },
526
+ AudioVolumeUp: { keyCode: 175, code: 'AudioVolumeUp', key: 'AudioVolumeUp' },
527
+ MediaTrackNext: {
528
+ keyCode: 176,
529
+ code: 'MediaTrackNext',
530
+ key: 'MediaTrackNext',
531
+ },
532
+ MediaTrackPrevious: {
533
+ keyCode: 177,
534
+ code: 'MediaTrackPrevious',
535
+ key: 'MediaTrackPrevious',
536
+ },
537
+ MediaStop: { keyCode: 178, code: 'MediaStop', key: 'MediaStop' },
538
+ MediaPlayPause: {
539
+ keyCode: 179,
540
+ code: 'MediaPlayPause',
541
+ key: 'MediaPlayPause',
542
+ },
543
+ Semicolon: { keyCode: 186, code: 'Semicolon', shiftKey: ':', key: ';' },
544
+ Equal: { keyCode: 187, code: 'Equal', shiftKey: '+', key: '=' },
545
+ NumpadEqual: { keyCode: 187, code: 'NumpadEqual', key: '=', location: 3 },
546
+ Comma: { keyCode: 188, code: 'Comma', shiftKey: '<', key: ',' },
547
+ Minus: { keyCode: 189, code: 'Minus', shiftKey: '_', key: '-' },
548
+ Period: { keyCode: 190, code: 'Period', shiftKey: '>', key: '.' },
549
+ Slash: { keyCode: 191, code: 'Slash', shiftKey: '?', key: '/' },
550
+ Backquote: { keyCode: 192, code: 'Backquote', shiftKey: '~', key: '`' },
551
+ BracketLeft: { keyCode: 219, code: 'BracketLeft', shiftKey: '{', key: '[' },
552
+ Backslash: { keyCode: 220, code: 'Backslash', shiftKey: '|', key: '\\' },
553
+ BracketRight: { keyCode: 221, code: 'BracketRight', shiftKey: '}', key: ']' },
554
+ Quote: { keyCode: 222, code: 'Quote', shiftKey: '"', key: "'" },
555
+ AltGraph: { keyCode: 225, code: 'AltGraph', key: 'AltGraph' },
556
+ Props: { keyCode: 247, code: 'Props', key: 'CrSel' },
557
+ Cancel: { keyCode: 3, key: 'Cancel', code: 'Abort' },
558
+ Clear: { keyCode: 12, key: 'Clear', code: 'Numpad5', location: 3 },
559
+ Shift: { keyCode: 16, key: 'Shift', code: 'ShiftLeft', location: 1 },
560
+ Control: { keyCode: 17, key: 'Control', code: 'ControlLeft', location: 1 },
561
+ Alt: { keyCode: 18, key: 'Alt', code: 'AltLeft', location: 1 },
562
+ Accept: { keyCode: 30, key: 'Accept' },
563
+ ModeChange: { keyCode: 31, key: 'ModeChange' },
564
+ ' ': { keyCode: 32, key: ' ', code: 'Space' },
565
+ Print: { keyCode: 42, key: 'Print' },
566
+ Execute: { keyCode: 43, key: 'Execute', code: 'Open' },
567
+ '\u0000': { keyCode: 46, key: '\u0000', code: 'NumpadDecimal', location: 3 },
568
+ a: { keyCode: 65, key: 'a', code: 'KeyA' },
569
+ b: { keyCode: 66, key: 'b', code: 'KeyB' },
570
+ c: { keyCode: 67, key: 'c', code: 'KeyC' },
571
+ d: { keyCode: 68, key: 'd', code: 'KeyD' },
572
+ e: { keyCode: 69, key: 'e', code: 'KeyE' },
573
+ f: { keyCode: 70, key: 'f', code: 'KeyF' },
574
+ g: { keyCode: 71, key: 'g', code: 'KeyG' },
575
+ h: { keyCode: 72, key: 'h', code: 'KeyH' },
576
+ i: { keyCode: 73, key: 'i', code: 'KeyI' },
577
+ j: { keyCode: 74, key: 'j', code: 'KeyJ' },
578
+ k: { keyCode: 75, key: 'k', code: 'KeyK' },
579
+ l: { keyCode: 76, key: 'l', code: 'KeyL' },
580
+ m: { keyCode: 77, key: 'm', code: 'KeyM' },
581
+ n: { keyCode: 78, key: 'n', code: 'KeyN' },
582
+ o: { keyCode: 79, key: 'o', code: 'KeyO' },
583
+ p: { keyCode: 80, key: 'p', code: 'KeyP' },
584
+ q: { keyCode: 81, key: 'q', code: 'KeyQ' },
585
+ r: { keyCode: 82, key: 'r', code: 'KeyR' },
586
+ s: { keyCode: 83, key: 's', code: 'KeyS' },
587
+ t: { keyCode: 84, key: 't', code: 'KeyT' },
588
+ u: { keyCode: 85, key: 'u', code: 'KeyU' },
589
+ v: { keyCode: 86, key: 'v', code: 'KeyV' },
590
+ w: { keyCode: 87, key: 'w', code: 'KeyW' },
591
+ x: { keyCode: 88, key: 'x', code: 'KeyX' },
592
+ y: { keyCode: 89, key: 'y', code: 'KeyY' },
593
+ z: { keyCode: 90, key: 'z', code: 'KeyZ' },
594
+ Meta: { keyCode: 91, key: 'Meta', code: 'MetaLeft', location: 1 },
595
+ '*': { keyCode: 106, key: '*', code: 'NumpadMultiply', location: 3 },
596
+ '+': { keyCode: 107, key: '+', code: 'NumpadAdd', location: 3 },
597
+ '-': { keyCode: 109, key: '-', code: 'NumpadSubtract', location: 3 },
598
+ '/': { keyCode: 111, key: '/', code: 'NumpadDivide', location: 3 },
599
+ ';': { keyCode: 186, key: ';', code: 'Semicolon' },
600
+ '=': { keyCode: 187, key: '=', code: 'Equal' },
601
+ ',': { keyCode: 188, key: ',', code: 'Comma' },
602
+ '.': { keyCode: 190, key: '.', code: 'Period' },
603
+ '`': { keyCode: 192, key: '`', code: 'Backquote' },
604
+ '[': { keyCode: 219, key: '[', code: 'BracketLeft' },
605
+ '\\': { keyCode: 220, key: '\\', code: 'Backslash' },
606
+ ']': { keyCode: 221, key: ']', code: 'BracketRight' },
607
+ "'": { keyCode: 222, key: "'", code: 'Quote' },
608
+ Attn: { keyCode: 246, key: 'Attn' },
609
+ CrSel: { keyCode: 247, key: 'CrSel', code: 'Props' },
610
+ ExSel: { keyCode: 248, key: 'ExSel' },
611
+ EraseEof: { keyCode: 249, key: 'EraseEof' },
612
+ Play: { keyCode: 250, key: 'Play' },
613
+ ZoomOut: { keyCode: 251, key: 'ZoomOut' },
614
+ ')': { keyCode: 48, key: ')', code: 'Digit0' },
615
+ '!': { keyCode: 49, key: '!', code: 'Digit1' },
616
+ '@': { keyCode: 50, key: '@', code: 'Digit2' },
617
+ '#': { keyCode: 51, key: '#', code: 'Digit3' },
618
+ $: { keyCode: 52, key: '$', code: 'Digit4' },
619
+ '%': { keyCode: 53, key: '%', code: 'Digit5' },
620
+ '^': { keyCode: 54, key: '^', code: 'Digit6' },
621
+ '&': { keyCode: 55, key: '&', code: 'Digit7' },
622
+ '(': { keyCode: 57, key: '(', code: 'Digit9' },
623
+ A: { keyCode: 65, key: 'A', code: 'KeyA' },
624
+ B: { keyCode: 66, key: 'B', code: 'KeyB' },
625
+ C: { keyCode: 67, key: 'C', code: 'KeyC' },
626
+ D: { keyCode: 68, key: 'D', code: 'KeyD' },
627
+ E: { keyCode: 69, key: 'E', code: 'KeyE' },
628
+ F: { keyCode: 70, key: 'F', code: 'KeyF' },
629
+ G: { keyCode: 71, key: 'G', code: 'KeyG' },
630
+ H: { keyCode: 72, key: 'H', code: 'KeyH' },
631
+ I: { keyCode: 73, key: 'I', code: 'KeyI' },
632
+ J: { keyCode: 74, key: 'J', code: 'KeyJ' },
633
+ K: { keyCode: 75, key: 'K', code: 'KeyK' },
634
+ L: { keyCode: 76, key: 'L', code: 'KeyL' },
635
+ M: { keyCode: 77, key: 'M', code: 'KeyM' },
636
+ N: { keyCode: 78, key: 'N', code: 'KeyN' },
637
+ O: { keyCode: 79, key: 'O', code: 'KeyO' },
638
+ P: { keyCode: 80, key: 'P', code: 'KeyP' },
639
+ Q: { keyCode: 81, key: 'Q', code: 'KeyQ' },
640
+ R: { keyCode: 82, key: 'R', code: 'KeyR' },
641
+ S: { keyCode: 83, key: 'S', code: 'KeyS' },
642
+ T: { keyCode: 84, key: 'T', code: 'KeyT' },
643
+ U: { keyCode: 85, key: 'U', code: 'KeyU' },
644
+ V: { keyCode: 86, key: 'V', code: 'KeyV' },
645
+ W: { keyCode: 87, key: 'W', code: 'KeyW' },
646
+ X: { keyCode: 88, key: 'X', code: 'KeyX' },
647
+ Y: { keyCode: 89, key: 'Y', code: 'KeyY' },
648
+ Z: { keyCode: 90, key: 'Z', code: 'KeyZ' },
649
+ ':': { keyCode: 186, key: ':', code: 'Semicolon' },
650
+ '<': { keyCode: 188, key: '<', code: 'Comma' },
651
+ _: { keyCode: 189, key: '_', code: 'Minus' },
652
+ '>': { keyCode: 190, key: '>', code: 'Period' },
653
+ '?': { keyCode: 191, key: '?', code: 'Slash' },
654
+ '~': { keyCode: 192, key: '~', code: 'Backquote' },
655
+ '{': { keyCode: 219, key: '{', code: 'BracketLeft' },
656
+ '|': { keyCode: 220, key: '|', code: 'Backslash' },
657
+ '}': { keyCode: 221, key: '}', code: 'BracketRight' },
658
+ '"': { keyCode: 222, key: '"', code: 'Quote' },
659
+ SoftLeft: { key: 'SoftLeft', code: 'SoftLeft', location: 4 },
660
+ SoftRight: { key: 'SoftRight', code: 'SoftRight', location: 4 },
661
+ Camera: { keyCode: 44, key: 'Camera', code: 'Camera', location: 4 },
662
+ Call: { key: 'Call', code: 'Call', location: 4 },
663
+ EndCall: { keyCode: 95, key: 'EndCall', code: 'EndCall', location: 4 },
664
+ VolumeDown: {
665
+ keyCode: 182,
666
+ key: 'VolumeDown',
667
+ code: 'VolumeDown',
668
+ location: 4,
669
+ },
670
+ VolumeUp: { keyCode: 183, key: 'VolumeUp', code: 'VolumeUp', location: 4 },
671
+ };
672
+
673
+ // Add lowercase key mappings
674
+ const lowerCaseKeyDefinitions = Object.entries(_keyDefinitions).reduce(
675
+ (acc, [key, definition]) => {
676
+ const lowerKey = key.toLowerCase();
677
+ if (lowerKey !== key) {
678
+ acc[lowerKey] = definition;
679
+ }
680
+ return acc;
681
+ },
682
+ {} as Record<string, KeyDefinition>,
683
+ );
684
+
685
+ export const getKeyDefinition = (key: string): KeyInput => {
686
+ const lowerKey = key.toLowerCase();
687
+ if (lowerCaseKeyDefinitions[lowerKey]) {
688
+ return lowerCaseKeyDefinitions[lowerKey].key as KeyInput;
689
+ }
690
+ return key as KeyInput;
691
+ };
692
+
693
+ export const isMac =
694
+ typeof window !== 'undefined'
695
+ ? /Mac|iPod|iPhone|iPad/.test(window.navigator.platform)
696
+ : process.platform === 'darwin';
697
+
698
+ //ui-tars key event mapping
699
+ const keyMap: Record<string, KeyInput> = {
700
+ return: _keyDefinitions.Enter.key as KeyInput,
701
+ enter: _keyDefinitions.Enter.key as KeyInput,
702
+ ctrl: isMac
703
+ ? (_keyDefinitions.Meta.key as KeyInput)
704
+ : (_keyDefinitions.Control.key as KeyInput),
705
+ shift: _keyDefinitions.Shift.key as KeyInput,
706
+ alt: _keyDefinitions.Alt.key as KeyInput,
707
+ space: _keyDefinitions.Space.key as KeyInput,
708
+ 'page down': _keyDefinitions.PageDown.key as KeyInput,
709
+ pagedown: _keyDefinitions.PageDown.key as KeyInput,
710
+ 'page up': _keyDefinitions.PageUp.key as KeyInput,
711
+ pageup: _keyDefinitions.PageUp.key as KeyInput,
712
+ };
713
+
714
+ export function transformHotkeyInput(keyInput: string): string[] {
715
+ // page down
716
+ if (keyMap[keyInput.toLowerCase()]) {
717
+ return [getKeyDefinition(keyMap[keyInput.toLowerCase()])];
718
+ }
719
+
720
+ return keyInput.split(' ').map((key) => {
721
+ return getKeyDefinition(keyMap[key.toLowerCase()] || key);
722
+ });
723
+ }