@witchcraft/spellcraft 0.0.1

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 (367) hide show
  1. package/README.md +579 -0
  2. package/dist/core/EmulatedEvent.d.ts +10 -0
  3. package/dist/core/EmulatedEvent.js +19 -0
  4. package/dist/core/Emulator.d.ts +74 -0
  5. package/dist/core/Emulator.js +153 -0
  6. package/dist/core/ShortcutManagerManager.d.ts +103 -0
  7. package/dist/core/ShortcutManagerManager.js +267 -0
  8. package/dist/core/addCommand.d.ts +7 -0
  9. package/dist/core/addCommand.js +7 -0
  10. package/dist/core/addKey.d.ts +7 -0
  11. package/dist/core/addKey.js +7 -0
  12. package/dist/core/addShortcut.d.ts +7 -0
  13. package/dist/core/addShortcut.js +7 -0
  14. package/dist/core/attach.d.ts +10 -0
  15. package/dist/core/attach.js +13 -0
  16. package/dist/core/createCommand.d.ts +4 -0
  17. package/dist/core/createCommand.js +11 -0
  18. package/dist/core/createCommands.d.ts +11 -0
  19. package/dist/core/createCommands.js +20 -0
  20. package/dist/core/createCondition.d.ts +7 -0
  21. package/dist/core/createCondition.js +11 -0
  22. package/dist/core/createContext.d.ts +2 -0
  23. package/dist/core/createContext.js +8 -0
  24. package/dist/core/createKey.d.ts +10 -0
  25. package/dist/core/createKey.js +35 -0
  26. package/dist/core/createKeys.d.ts +5 -0
  27. package/dist/core/createKeys.js +36 -0
  28. package/dist/core/createManager.d.ts +81 -0
  29. package/dist/core/createManager.js +83 -0
  30. package/dist/core/createManagerEventListeners.d.ts +4 -0
  31. package/dist/core/createManagerEventListeners.js +130 -0
  32. package/dist/core/createManagerOptions.d.ts +8 -0
  33. package/dist/core/createManagerOptions.js +17 -0
  34. package/dist/core/createShortcut.d.ts +8 -0
  35. package/dist/core/createShortcut.js +24 -0
  36. package/dist/core/createShortcuts.d.ts +13 -0
  37. package/dist/core/createShortcuts.js +20 -0
  38. package/dist/core/detach.d.ts +10 -0
  39. package/dist/core/detach.js +6 -0
  40. package/dist/core/index.d.ts +32 -0
  41. package/dist/core/index.js +32 -0
  42. package/dist/core/removeCommand.d.ts +7 -0
  43. package/dist/core/removeCommand.js +7 -0
  44. package/dist/core/removeKey.d.ts +7 -0
  45. package/dist/core/removeKey.js +7 -0
  46. package/dist/core/removeShortcut.d.ts +7 -0
  47. package/dist/core/removeShortcut.js +7 -0
  48. package/dist/core/setCommandProp.d.ts +17 -0
  49. package/dist/core/setCommandProp.js +96 -0
  50. package/dist/core/setCommandsProp.d.ts +15 -0
  51. package/dist/core/setCommandsProp.js +94 -0
  52. package/dist/core/setKeyProp.d.ts +16 -0
  53. package/dist/core/setKeyProp.js +47 -0
  54. package/dist/core/setKeysProp.d.ts +10 -0
  55. package/dist/core/setKeysProp.js +166 -0
  56. package/dist/core/setManagerProp.d.ts +34 -0
  57. package/dist/core/setManagerProp.js +54 -0
  58. package/dist/core/setShortcutProp.d.ts +9 -0
  59. package/dist/core/setShortcutProp.js +50 -0
  60. package/dist/core/setShortcutsProp.d.ts +12 -0
  61. package/dist/core/setShortcutsProp.js +93 -0
  62. package/dist/defaults/KeysSorter.d.ts +35 -0
  63. package/dist/defaults/KeysSorter.js +20 -0
  64. package/dist/defaults/Stringifier.d.ts +66 -0
  65. package/dist/defaults/Stringifier.js +119 -0
  66. package/dist/defaults/defaultConditionEquals.d.ts +19 -0
  67. package/dist/defaults/defaultConditionEquals.js +5 -0
  68. package/dist/defaults/defaultManagerCallback.d.ts +7 -0
  69. package/dist/defaults/defaultManagerCallback.js +5 -0
  70. package/dist/helpers/KnownError.d.ts +8 -0
  71. package/dist/helpers/KnownError.js +3 -0
  72. package/dist/helpers/calculateAndSetPositionAndWidth.d.ts +13 -0
  73. package/dist/helpers/calculateAndSetPositionAndWidth.js +18 -0
  74. package/dist/helpers/calculateLayoutSize.d.ts +9 -0
  75. package/dist/helpers/calculateLayoutSize.js +13 -0
  76. package/dist/helpers/doesShortcutConflict.d.ts +18 -0
  77. package/dist/helpers/doesShortcutConflict.js +42 -0
  78. package/dist/helpers/equalsCommand.d.ts +7 -0
  79. package/dist/helpers/equalsCommand.js +4 -0
  80. package/dist/helpers/equalsContext.d.ts +7 -0
  81. package/dist/helpers/equalsContext.js +19 -0
  82. package/dist/helpers/equalsShortcut.d.ts +9 -0
  83. package/dist/helpers/equalsShortcut.js +7 -0
  84. package/dist/helpers/forceClear.d.ts +12 -0
  85. package/dist/helpers/forceClear.js +16 -0
  86. package/dist/helpers/forceUpdateNativeKeysState.d.ts +5 -0
  87. package/dist/helpers/forceUpdateNativeKeysState.js +4 -0
  88. package/dist/helpers/generateKeyShortcutMap.d.ts +23 -0
  89. package/dist/helpers/generateKeyShortcutMap.js +64 -0
  90. package/dist/helpers/getKeyFromEventCode.d.ts +15 -0
  91. package/dist/helpers/getKeyFromEventCode.js +36 -0
  92. package/dist/helpers/getKeyFromIdOrVariant.d.ts +4 -0
  93. package/dist/helpers/getKeyFromIdOrVariant.js +26 -0
  94. package/dist/helpers/getKeyboardLayoutMap.d.ts +5 -0
  95. package/dist/helpers/getKeyboardLayoutMap.js +7 -0
  96. package/dist/helpers/getLabel.d.ts +9 -0
  97. package/dist/helpers/getLabel.js +6 -0
  98. package/dist/helpers/getTriggerableShortcut.d.ts +6 -0
  99. package/dist/helpers/getTriggerableShortcut.js +25 -0
  100. package/dist/helpers/index.d.ts +28 -0
  101. package/dist/helpers/index.js +28 -0
  102. package/dist/helpers/isValidManager.d.ts +3 -0
  103. package/dist/helpers/isValidManager.js +20 -0
  104. package/dist/helpers/isValidShortcut.d.ts +3 -0
  105. package/dist/helpers/isValidShortcut.js +10 -0
  106. package/dist/helpers/labelWithEvent.d.ts +13 -0
  107. package/dist/helpers/labelWithEvent.js +20 -0
  108. package/dist/helpers/labelWithKeyboardMap.d.ts +15 -0
  109. package/dist/helpers/labelWithKeyboardMap.js +17 -0
  110. package/dist/helpers/managerToStorableClone.d.ts +12 -0
  111. package/dist/helpers/managerToStorableClone.js +13 -0
  112. package/dist/helpers/onKeyboardLayoutChange.d.ts +10 -0
  113. package/dist/helpers/onKeyboardLayoutChange.js +7 -0
  114. package/dist/helpers/safeSetManagerChain.d.ts +20 -0
  115. package/dist/helpers/safeSetManagerChain.js +37 -0
  116. package/dist/helpers/shortcutCanExecuteIn.d.ts +4 -0
  117. package/dist/helpers/shortcutCanExecuteIn.js +9 -0
  118. package/dist/helpers/shortcutIsTriggerableBy.d.ts +2 -0
  119. package/dist/helpers/shortcutIsTriggerableBy.js +5 -0
  120. package/dist/helpers/shortcutSwapChords.d.ts +75 -0
  121. package/dist/helpers/shortcutSwapChords.js +118 -0
  122. package/dist/helpers/virtualPress.d.ts +13 -0
  123. package/dist/helpers/virtualPress.js +15 -0
  124. package/dist/helpers/virtualRelease.d.ts +5 -0
  125. package/dist/helpers/virtualRelease.js +15 -0
  126. package/dist/helpers/virtualToggle.d.ts +7 -0
  127. package/dist/helpers/virtualToggle.js +16 -0
  128. package/dist/internal/addToChain.d.ts +3 -0
  129. package/dist/internal/addToChain.js +27 -0
  130. package/dist/internal/areValidKeys.d.ts +7 -0
  131. package/dist/internal/areValidKeys.js +28 -0
  132. package/dist/internal/areValidVariants.d.ts +4 -0
  133. package/dist/internal/areValidVariants.js +45 -0
  134. package/dist/internal/checkTrigger.d.ts +2 -0
  135. package/dist/internal/checkTrigger.js +47 -0
  136. package/dist/internal/checkUntrigger.d.ts +2 -0
  137. package/dist/internal/checkUntrigger.js +18 -0
  138. package/dist/internal/cloneLastChord.d.ts +4 -0
  139. package/dist/internal/cloneLastChord.js +5 -0
  140. package/dist/internal/containsPossibleToggleChords.d.ts +13 -0
  141. package/dist/internal/containsPossibleToggleChords.js +65 -0
  142. package/dist/internal/errorTextAdd.d.ts +1 -0
  143. package/dist/internal/errorTextAdd.js +11 -0
  144. package/dist/internal/errorTextInUse.d.ts +1 -0
  145. package/dist/internal/errorTextInUse.js +8 -0
  146. package/dist/internal/errorTextRemove.d.ts +1 -0
  147. package/dist/internal/errorTextRemove.js +8 -0
  148. package/dist/internal/getModifierState.d.ts +2 -0
  149. package/dist/internal/getModifierState.js +7 -0
  150. package/dist/internal/getPressedKeys.d.ts +7 -0
  151. package/dist/internal/getPressedKeys.js +18 -0
  152. package/dist/internal/getPressedModifierKeys.d.ts +2 -0
  153. package/dist/internal/getPressedModifierKeys.js +10 -0
  154. package/dist/internal/getPressedNonModifierKeys.d.ts +7 -0
  155. package/dist/internal/getPressedNonModifierKeys.js +11 -0
  156. package/dist/internal/inChain.d.ts +5 -0
  157. package/dist/internal/inChain.js +14 -0
  158. package/dist/internal/isValidChain.d.ts +10 -0
  159. package/dist/internal/isValidChain.js +22 -0
  160. package/dist/internal/isValidChord.d.ts +11 -0
  161. package/dist/internal/isValidChord.js +59 -0
  162. package/dist/internal/isValidCommand.d.ts +12 -0
  163. package/dist/internal/isValidCommand.js +20 -0
  164. package/dist/internal/keyOrder.d.ts +6 -0
  165. package/dist/internal/keyOrder.js +14 -0
  166. package/dist/internal/removeFromChain.d.ts +3 -0
  167. package/dist/internal/removeFromChain.js +32 -0
  168. package/dist/internal/safeSetEmulatedToggleState.d.ts +4 -0
  169. package/dist/internal/safeSetEmulatedToggleState.js +13 -0
  170. package/dist/internal/setKeysState.d.ts +8 -0
  171. package/dist/internal/setKeysState.js +42 -0
  172. package/dist/internal/updateNativeKeysState.d.ts +14 -0
  173. package/dist/internal/updateNativeKeysState.js +58 -0
  174. package/dist/layouts/createLayout.d.ts +25 -0
  175. package/dist/layouts/createLayout.js +221 -0
  176. package/dist/module.d.mts +13 -0
  177. package/dist/module.json +9 -0
  178. package/dist/module.mjs +40 -0
  179. package/dist/runtime/composables/useLabeledByKeyboardLayoutMap.d.ts +9 -0
  180. package/dist/runtime/composables/useLabeledByKeyboardLayoutMap.js +19 -0
  181. package/dist/runtime/composables/usePointerCoords.d.ts +32 -0
  182. package/dist/runtime/composables/usePointerCoords.js +17 -0
  183. package/dist/runtime/composables/useShortcutManagerContextCount.d.ts +14 -0
  184. package/dist/runtime/composables/useShortcutManagerContextCount.js +61 -0
  185. package/dist/runtime/composables/useShortcutManagerKeysLayout.d.ts +18 -0
  186. package/dist/runtime/composables/useShortcutManagerKeysLayout.js +22 -0
  187. package/dist/runtime/composables/useShortcutManagerVirtualPress.d.ts +6 -0
  188. package/dist/runtime/composables/useShortcutManagerVirtualPress.js +24 -0
  189. package/dist/runtime/types.d.ts +10 -0
  190. package/dist/runtime/types.js +1 -0
  191. package/dist/runtime/utils/shortcutToId.d.ts +5 -0
  192. package/dist/runtime/utils/shortcutToId.js +6 -0
  193. package/dist/types/commands.d.ts +113 -0
  194. package/dist/types/commands.js +0 -0
  195. package/dist/types/condition.d.ts +29 -0
  196. package/dist/types/condition.js +0 -0
  197. package/dist/types/context.d.ts +18 -0
  198. package/dist/types/context.js +0 -0
  199. package/dist/types/enums.d.ts +186 -0
  200. package/dist/types/enums.js +70 -0
  201. package/dist/types/general.d.ts +92 -0
  202. package/dist/types/general.js +0 -0
  203. package/dist/types/index.d.ts +8 -0
  204. package/dist/types/index.js +8 -0
  205. package/dist/types/keys.d.ts +332 -0
  206. package/dist/types/keys.js +0 -0
  207. package/dist/types/manager.d.ts +249 -0
  208. package/dist/types/manager.js +0 -0
  209. package/dist/types/plugins.d.ts +1 -0
  210. package/dist/types/plugins.js +0 -0
  211. package/dist/types/shortcuts.d.ts +144 -0
  212. package/dist/types/shortcuts.js +0 -0
  213. package/dist/types/utils.d.ts +1 -0
  214. package/dist/types/utils.js +0 -0
  215. package/dist/types.d.mts +3 -0
  216. package/dist/utils/chainContainsSubset.d.ts +27 -0
  217. package/dist/utils/chainContainsSubset.js +45 -0
  218. package/dist/utils/cloneChain.d.ts +2 -0
  219. package/dist/utils/cloneChain.js +11 -0
  220. package/dist/utils/cloneKey.d.ts +3 -0
  221. package/dist/utils/cloneKey.js +26 -0
  222. package/dist/utils/containsKey.d.ts +7 -0
  223. package/dist/utils/containsKey.js +4 -0
  224. package/dist/utils/dedupeKeys.d.ts +9 -0
  225. package/dist/utils/dedupeKeys.js +9 -0
  226. package/dist/utils/equalsKey.d.ts +12 -0
  227. package/dist/utils/equalsKey.js +13 -0
  228. package/dist/utils/equalsKeys.d.ts +24 -0
  229. package/dist/utils/equalsKeys.js +15 -0
  230. package/dist/utils/index.d.ts +14 -0
  231. package/dist/utils/index.js +14 -0
  232. package/dist/utils/isAnyKey.d.ts +5 -0
  233. package/dist/utils/isAnyKey.js +5 -0
  234. package/dist/utils/isMouseKey.d.ts +5 -0
  235. package/dist/utils/isMouseKey.js +20 -0
  236. package/dist/utils/isNormalKey.d.ts +5 -0
  237. package/dist/utils/isNormalKey.js +5 -0
  238. package/dist/utils/isTriggerKey.d.ts +5 -0
  239. package/dist/utils/isTriggerKey.js +3 -0
  240. package/dist/utils/isWheelKey.d.ts +5 -0
  241. package/dist/utils/isWheelKey.js +11 -0
  242. package/dist/utils/mapKeys.d.ts +8 -0
  243. package/dist/utils/mapKeys.js +5 -0
  244. package/dist/utils/removeKeys.d.ts +7 -0
  245. package/dist/utils/removeKeys.js +4 -0
  246. package/package.json +156 -0
  247. package/src/core/EmulatedEvent.ts +29 -0
  248. package/src/core/Emulator.ts +185 -0
  249. package/src/core/ShortcutManagerManager.ts +380 -0
  250. package/src/core/addCommand.ts +24 -0
  251. package/src/core/addKey.ts +25 -0
  252. package/src/core/addShortcut.ts +24 -0
  253. package/src/core/attach.ts +27 -0
  254. package/src/core/createCommand.ts +24 -0
  255. package/src/core/createCommands.ts +45 -0
  256. package/src/core/createCondition.ts +21 -0
  257. package/src/core/createContext.ts +14 -0
  258. package/src/core/createKey.ts +59 -0
  259. package/src/core/createKeys.ts +68 -0
  260. package/src/core/createManager.ts +209 -0
  261. package/src/core/createManagerEventListeners.ts +139 -0
  262. package/src/core/createManagerOptions.ts +29 -0
  263. package/src/core/createShortcut.ts +49 -0
  264. package/src/core/createShortcuts.ts +51 -0
  265. package/src/core/detach.ts +21 -0
  266. package/src/core/index.ts +35 -0
  267. package/src/core/removeCommand.ts +25 -0
  268. package/src/core/removeKey.ts +25 -0
  269. package/src/core/removeShortcut.ts +24 -0
  270. package/src/core/setCommandProp.ts +140 -0
  271. package/src/core/setCommandsProp.ts +128 -0
  272. package/src/core/setKeyProp.ts +80 -0
  273. package/src/core/setKeysProp.ts +205 -0
  274. package/src/core/setManagerProp.ts +111 -0
  275. package/src/core/setShortcutProp.ts +89 -0
  276. package/src/core/setShortcutsProp.ts +124 -0
  277. package/src/defaults/KeysSorter.ts +55 -0
  278. package/src/defaults/Stringifier.ts +234 -0
  279. package/src/defaults/defaultConditionEquals.ts +29 -0
  280. package/src/defaults/defaultManagerCallback.ts +14 -0
  281. package/src/helpers/KnownError.ts +13 -0
  282. package/src/helpers/calculateAndSetPositionAndWidth.ts +30 -0
  283. package/src/helpers/calculateLayoutSize.ts +22 -0
  284. package/src/helpers/doesShortcutConflict.ts +72 -0
  285. package/src/helpers/equalsCommand.ts +18 -0
  286. package/src/helpers/equalsContext.ts +29 -0
  287. package/src/helpers/equalsShortcut.ts +34 -0
  288. package/src/helpers/forceClear.ts +31 -0
  289. package/src/helpers/forceUpdateNativeKeysState.ts +9 -0
  290. package/src/helpers/generateKeyShortcutMap.ts +113 -0
  291. package/src/helpers/getKeyFromEventCode.ts +67 -0
  292. package/src/helpers/getKeyFromIdOrVariant.ts +33 -0
  293. package/src/helpers/getKeyboardLayoutMap.ts +13 -0
  294. package/src/helpers/getLabel.ts +15 -0
  295. package/src/helpers/getTriggerableShortcut.ts +37 -0
  296. package/src/helpers/index.ts +30 -0
  297. package/src/helpers/isValidManager.ts +29 -0
  298. package/src/helpers/isValidShortcut.ts +20 -0
  299. package/src/helpers/labelWithEvent.ts +41 -0
  300. package/src/helpers/labelWithKeyboardMap.ts +37 -0
  301. package/src/helpers/managerToStorableClone.ts +26 -0
  302. package/src/helpers/onKeyboardLayoutChange.ts +17 -0
  303. package/src/helpers/safeSetManagerChain.ts +66 -0
  304. package/src/helpers/shortcutCanExecuteIn.ts +24 -0
  305. package/src/helpers/shortcutIsTriggerableBy.ts +15 -0
  306. package/src/helpers/shortcutSwapChords.ts +240 -0
  307. package/src/helpers/virtualPress.ts +34 -0
  308. package/src/helpers/virtualRelease.ts +25 -0
  309. package/src/helpers/virtualToggle.ts +28 -0
  310. package/src/internal/addToChain.ts +40 -0
  311. package/src/internal/areValidKeys.ts +40 -0
  312. package/src/internal/areValidVariants.ts +59 -0
  313. package/src/internal/checkTrigger.ts +55 -0
  314. package/src/internal/checkUntrigger.ts +26 -0
  315. package/src/internal/cloneLastChord.ts +10 -0
  316. package/src/internal/containsPossibleToggleChords.ts +91 -0
  317. package/src/internal/errorTextAdd.ts +18 -0
  318. package/src/internal/errorTextInUse.ts +10 -0
  319. package/src/internal/errorTextRemove.ts +10 -0
  320. package/src/internal/getModifierState.ts +15 -0
  321. package/src/internal/getPressedKeys.ts +26 -0
  322. package/src/internal/getPressedModifierKeys.ts +14 -0
  323. package/src/internal/getPressedNonModifierKeys.ts +19 -0
  324. package/src/internal/inChain.ts +25 -0
  325. package/src/internal/isValidChain.ts +42 -0
  326. package/src/internal/isValidChord.ts +87 -0
  327. package/src/internal/isValidCommand.ts +35 -0
  328. package/src/internal/keyOrder.ts +24 -0
  329. package/src/internal/removeFromChain.ts +46 -0
  330. package/src/internal/safeSetEmulatedToggleState.ts +23 -0
  331. package/src/internal/setKeysState.ts +71 -0
  332. package/src/internal/updateNativeKeysState.ts +84 -0
  333. package/src/layouts/createLayout.ts +328 -0
  334. package/src/module.ts +62 -0
  335. package/src/runtime/composables/useLabeledByKeyboardLayoutMap.ts +28 -0
  336. package/src/runtime/composables/usePointerCoords.ts +40 -0
  337. package/src/runtime/composables/useShortcutManagerContextCount.ts +81 -0
  338. package/src/runtime/composables/useShortcutManagerKeysLayout.ts +42 -0
  339. package/src/runtime/composables/useShortcutManagerVirtualPress.ts +30 -0
  340. package/src/runtime/types.ts +10 -0
  341. package/src/runtime/utils/shortcutToId.ts +14 -0
  342. package/src/types/commands.ts +148 -0
  343. package/src/types/condition.ts +35 -0
  344. package/src/types/context.ts +19 -0
  345. package/src/types/enums.ts +236 -0
  346. package/src/types/general.ts +117 -0
  347. package/src/types/index.ts +10 -0
  348. package/src/types/keys.ts +385 -0
  349. package/src/types/manager.ts +374 -0
  350. package/src/types/plugins.ts +32 -0
  351. package/src/types/shortcuts.ts +204 -0
  352. package/src/types/utils.ts +40 -0
  353. package/src/utils/chainContainsSubset.ts +97 -0
  354. package/src/utils/cloneChain.ts +13 -0
  355. package/src/utils/cloneKey.ts +33 -0
  356. package/src/utils/containsKey.ts +17 -0
  357. package/src/utils/dedupeKeys.ts +23 -0
  358. package/src/utils/equalsKey.ts +32 -0
  359. package/src/utils/equalsKeys.ts +50 -0
  360. package/src/utils/index.ts +16 -0
  361. package/src/utils/isAnyKey.ts +12 -0
  362. package/src/utils/isMouseKey.ts +27 -0
  363. package/src/utils/isNormalKey.ts +15 -0
  364. package/src/utils/isTriggerKey.ts +7 -0
  365. package/src/utils/isWheelKey.ts +18 -0
  366. package/src/utils/mapKeys.ts +21 -0
  367. package/src/utils/removeKeys.ts +16 -0
@@ -0,0 +1,9 @@
1
+ import { type Ref } from "vue";
2
+ import { labelWithKeyboardMap } from "../../helpers/labelWithKeyboardMap.js.js";
3
+ import type { Manager } from "../../types/manager.js.js";
4
+ /**
5
+ * Sets up {@link getKeyboardLayoutMap} and {@link onKeyboardLayoutChange} to use {@link labelWithKeyboardMap}.
6
+ *
7
+ * Returns a ref of the latest key labels to have been set.
8
+ */
9
+ export declare function useLabeledByKeyboardLayoutMap(manager: Manager): Ref<ReturnType<typeof labelWithKeyboardMap> | undefined>;
@@ -0,0 +1,19 @@
1
+ import { ref } from "vue";
2
+ import { getKeyboardLayoutMap } from "../../helpers/getKeyboardLayoutMap.js";
3
+ import { labelWithKeyboardMap } from "../../helpers/labelWithKeyboardMap.js";
4
+ import { onKeyboardLayoutChange } from "../../helpers/onKeyboardLayoutChange.js";
5
+ export function useLabeledByKeyboardLayoutMap(manager) {
6
+ const labeledByMap = ref();
7
+ void getKeyboardLayoutMap().then((map) => {
8
+ if (map) {
9
+ labeledByMap.value = labelWithKeyboardMap(manager, { map });
10
+ }
11
+ });
12
+ void onKeyboardLayoutChange(async () => {
13
+ const map = await getKeyboardLayoutMap();
14
+ if (map) {
15
+ labeledByMap.value = labelWithKeyboardMap(manager, { map });
16
+ }
17
+ });
18
+ return labeledByMap;
19
+ }
@@ -0,0 +1,32 @@
1
+ import { type ComputedRef } from "vue";
2
+ /**
3
+ * Returns a set of coordinates that includes an initial offset.
4
+ *
5
+ * For use with drag or similar events.
6
+ *
7
+ * `setInitialOffset` should be called at drag start.
8
+ *
9
+ * `setPointerCoords` can then be called on drag move.
10
+ *
11
+ * And `coords` will reflect the coordinates of the event + the initial offset.
12
+ *
13
+ * This can then be used to position an element and it won't jump, it will stay grabbed from where the user initially grabbed it.
14
+ */
15
+ export declare const usePointerCoords: () => {
16
+ pointerCoords: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ coords: ComputedRef<{
21
+ x: number;
22
+ y: number;
23
+ }>;
24
+ setPointerCoords: (e: {
25
+ clientX: number;
26
+ clientY: number;
27
+ }) => void;
28
+ setInitialPointerOffset: (e: {
29
+ clientX: number;
30
+ clientY: number;
31
+ }, el: HTMLElement) => void;
32
+ };
@@ -0,0 +1,17 @@
1
+ import { computed, reactive } from "vue";
2
+ export const usePointerCoords = () => {
3
+ const pointerCoords = reactive({ x: 0, y: 0 });
4
+ const offsetCoords = reactive({ x: 0, y: 0 });
5
+ const coords = computed(() => ({ x: pointerCoords.x - offsetCoords.x, y: pointerCoords.y - offsetCoords.y }));
6
+ const setPointerCoords = (e) => {
7
+ pointerCoords.x = e.clientX;
8
+ pointerCoords.y = e.clientY;
9
+ };
10
+ const setInitialPointerOffset = (e, el) => {
11
+ setPointerCoords(e);
12
+ const clientRect = el.getBoundingClientRect();
13
+ offsetCoords.x = pointerCoords.x - clientRect.x;
14
+ offsetCoords.y = pointerCoords.y - clientRect.y;
15
+ };
16
+ return { pointerCoords, coords, setPointerCoords, setInitialPointerOffset };
17
+ };
@@ -0,0 +1,14 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ import type { Manager } from "../../types/manager.js.js";
3
+ import type { ContextInfo } from "../types.js.js";
4
+ /**
5
+ * Updates the count of the ctx variables depending on how many shortcuts are using the variable. Requires shortcuts use the expressit library to set the ast property of conditions.
6
+ *
7
+ * Useful to know if we can delete a ctx.
8
+ */
9
+ export declare function useShortcutManagerContextCount(manager: Ref<Manager> | ComputedRef<Manager>, context: Ref<ContextInfo>): {
10
+ addContext(ctx: string): void;
11
+ removeContext(ctx: string): void;
12
+ activateContext(ctx: string): void;
13
+ deactivateContext(ctx: string): void;
14
+ };
@@ -0,0 +1,61 @@
1
+ import { keys } from "@alanscodelog/utils/keys";
2
+ import { unreachable } from "@alanscodelog/utils/unreachable";
3
+ import { extractTokens } from "@witchcraft/expressit/utils/extractTokens";
4
+ import { watch } from "vue";
5
+ export function useShortcutManagerContextCount(manager, context) {
6
+ watch(() => manager.value.shortcuts.entries, (newShortcuts) => {
7
+ const rc = {};
8
+ for (const shortcut of newShortcuts) {
9
+ if (!("ast" in shortcut.condition)) continue;
10
+ const c = shortcut.condition.ast;
11
+ if (c) {
12
+ const tokens = extractTokens(c);
13
+ const seen = [];
14
+ for (const token of tokens) {
15
+ if (token.type === "VALUE") {
16
+ if (seen.includes(token.value)) continue;
17
+ seen.push(token.value);
18
+ rc[token.value] = rc[token.value] ? rc[token.value] + 1 : 1;
19
+ }
20
+ }
21
+ }
22
+ }
23
+ for (const ctx of keys(context.value)) {
24
+ context.value.count[ctx] = rc[ctx] ?? 0;
25
+ }
26
+ for (const ctx of keys(rc)) {
27
+ if (!context.value.isActive[ctx]) {
28
+ context.value.isActive[ctx] = false;
29
+ context.value.count[ctx] = rc[ctx];
30
+ }
31
+ }
32
+ }, { deep: true, immediate: true });
33
+ function addContext(ctx) {
34
+ if (!context.value.isActive[ctx]) {
35
+ context.value.isActive[ctx] = true;
36
+ context.value.count[ctx] = 0;
37
+ } else {
38
+ unreachable();
39
+ }
40
+ }
41
+ function removeContext(ctx) {
42
+ if (context.value.count[ctx] === 0) {
43
+ delete context.value.isActive[ctx];
44
+ delete context.value.count[ctx];
45
+ } else {
46
+ unreachable();
47
+ }
48
+ }
49
+ function activateContext(ctx) {
50
+ context.value.isActive[ctx] ||= true;
51
+ }
52
+ function deactivateContext(ctx) {
53
+ context.value.isActive[ctx] &&= false;
54
+ }
55
+ return {
56
+ addContext,
57
+ removeContext,
58
+ activateContext,
59
+ deactivateContext
60
+ };
61
+ }
@@ -0,0 +1,18 @@
1
+ import { type Ref } from "vue";
2
+ import type { Keys } from "../../types/keys.js.js";
3
+ /**
4
+ * Watches Keys.layout.x/y and listens to resize changes on the element containing the keys to update what the pixel height of the element should be and what the pixel keyWidth.
5
+ *
6
+ * While it also returns the width and the ratio, you should not set the element to them.
7
+ *
8
+ */
9
+ export declare const useShortcutManagerKeysLayout: (keys: Keys, keyboardEl: Ref<HTMLElement | null>) => {
10
+ width: Ref<number>;
11
+ height: Ref<number>;
12
+ ratio: Ref<number>;
13
+ keyWidth: Ref<number>;
14
+ layout: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ };
@@ -0,0 +1,22 @@
1
+ import { useGlobalResizeObserver } from "@witchcraft/ui/composables/useGlobalResizeObserver";
2
+ import { computed, reactive, ref, watch } from "vue";
3
+ export const useShortcutManagerKeysLayout = (keys, keyboardEl) => {
4
+ const layout = reactive({ x: keys.layout.x, y: keys.layout.y });
5
+ watch([() => keys.layout.x, () => keys.layout.y], ([x, y]) => {
6
+ layout.x = x;
7
+ layout.y = y;
8
+ });
9
+ const width = ref(0);
10
+ const keyWidth = computed(() => {
11
+ const val = width.value / layout.x;
12
+ return Number.isNaN(val) ? 1 : val;
13
+ });
14
+ const ratio = computed(() => layout.x / layout.y);
15
+ const height = computed(() => width.value / ratio.value);
16
+ useGlobalResizeObserver(keyboardEl, function updateSize() {
17
+ if (keyboardEl.value) {
18
+ width.value = Math.max(keyboardEl.value.offsetWidth, 1e3);
19
+ }
20
+ });
21
+ return { width, height, ratio, keyWidth, layout };
22
+ };
@@ -0,0 +1,6 @@
1
+ import { type Ref } from "vue";
2
+ import type { ManagerListener } from "../../types/index.js.js";
3
+ export declare function useShortcutManagerVirtualPress(): {
4
+ virtuallyPressedKeys: Ref<Record<string, boolean>>;
5
+ updateVirtuallyPressed: ManagerListener;
6
+ };
@@ -0,0 +1,24 @@
1
+ import { ref } from "vue";
2
+ export function useShortcutManagerVirtualPress() {
3
+ const virtuallyPressedKeys = ref({});
4
+ function updateVirtuallyPressed(arg) {
5
+ const { event, keys, isKeydown } = arg;
6
+ if (!event) {
7
+ for (const key of keys) {
8
+ if (isKeydown) {
9
+ virtuallyPressedKeys.value[key] = true;
10
+ } else {
11
+ delete virtuallyPressedKeys.value[key];
12
+ }
13
+ }
14
+ } else {
15
+ for (const key of keys) {
16
+ delete virtuallyPressedKeys.value[key];
17
+ }
18
+ }
19
+ }
20
+ return {
21
+ virtuallyPressedKeys,
22
+ updateVirtuallyPressed
23
+ };
24
+ }
@@ -0,0 +1,10 @@
1
+ export interface Register {
2
+ }
3
+ type ExtendedContextInfo = Register extends {
4
+ ExtendedContextInfo: infer T;
5
+ } ? T : unknown;
6
+ export type ContextInfo = ExtendedContextInfo & {
7
+ count: Record<string, number>;
8
+ isActive: Record<string, boolean>;
9
+ };
10
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { PickManager } from "../../types/general.js.js";
2
+ import type { Manager } from "../../types/manager.js.js";
3
+ import type { Shortcut } from "../../types/shortcuts.js.js";
4
+ /** Turns a shortcut into an id to use in a v-for loop. */
5
+ export declare const shortcutToId: (shortcut: Shortcut, manager: PickManager<"options", "stringifier"> & Pick<Manager, "keys">) => string;
@@ -0,0 +1,6 @@
1
+ export const shortcutToId = (shortcut, manager) => [
2
+ shortcut.enabled,
3
+ manager.options.stringifier.stringify(shortcut.chain, manager),
4
+ shortcut.command ?? "",
5
+ shortcut.condition.text
6
+ ].join("--");
@@ -0,0 +1,113 @@
1
+ import type { Condition } from "./condition.js";
2
+ import type { Context } from "./context.js";
3
+ import type { SHORTCUT_ERROR } from "./enums.js";
4
+ import type { PickManager } from "./general.js";
5
+ import type { AnyInputEvent, Manager, MinimalInputEvent } from "./manager.js";
6
+ import type { Shortcut } from "./shortcuts.js";
7
+ export type RawCommand<TName extends string = string> = Pick<Command<TName>, "name"> & Partial<Command<TName>>;
8
+ export type CommandExecute<TName extends string = string> = <T extends AnyInputEvent | MinimalInputEvent = AnyInputEvent | MinimalInputEvent>(args: {
9
+ isKeydown: boolean;
10
+ command: Command<TName>;
11
+ shortcut?: Shortcut<TName> | undefined;
12
+ /**
13
+ * The event that triggered the command. It might be undefined if a virtual event triggered the key. It's typed as {@link AnyInputEvent} because you might also receive Emulated events from the {@link Emulator} if you use it. If you don't you can safely ignore the {@link EmulatedEvent} type or type the execute function as `CommandExecute<AnyInputEvent>`
14
+ */
15
+ event?: T;
16
+ /**
17
+ * The manager might be undefined. This is to allow calling the command manually without it.
18
+ */
19
+ manager?: Manager;
20
+ context: Context;
21
+ }) => void;
22
+ export interface Command<TName extends string = string, TExec extends CommandExecute<string> = CommandExecute<string>, TCondition extends Condition = Condition> {
23
+ readonly type: "command";
24
+ /**
25
+ * Unique string to identify the command by.
26
+ *
27
+ * Note that when changing a command's name, it is not an error for the old command to not exist in the manager. This is to allow for easier checking if a command can be added. If you need it to be an error, you can add a canSetCommand hook.
28
+ *
29
+ * @RequiresSet @OnHookable @CanHookable
30
+ */
31
+ readonly name: TName;
32
+ /**
33
+ * The function to execute when a shortcut triggers it's command. It is executed both on keydown and keyup (of the first released key) so be sure to check the isKeydown parameter so you don't trigger commands twice.
34
+ *
35
+ * The command itself is passed to it, and if it is managed by a manager it is also passed the shortcut, the manager itself, and the event of the last key that triggered it. Note the event might not exist when the manager needs to emulate a key release. See {@link Manager.autoReleaseDelay}.
36
+ *
37
+ * You should do `e.preventDefault` if you need it or haven't done so from {@link Manager.eventFilter}.
38
+ *
39
+ * You should also do {@link safeSetManagerChain} on keyup for most regular shortcuts. See it for details.
40
+ *
41
+ * See {@link Manager}.
42
+ *
43
+ * @RequiresSet @OnHookable @CanHookable
44
+ */
45
+ readonly execute?: TExec;
46
+ /**
47
+ * Commands may have an additional condition that must be met, apart from the shortcut's that triggered it.
48
+ *
49
+ * If the command is created without a condition, it is assigned a blank condition. If you are using a custom condition class, you should probably always pass a blank condition.
50
+ *
51
+ * @RequiresSet @OnHookable @CanHookable
52
+ */
53
+ readonly condition: TCondition;
54
+ /**
55
+ * A description of what the command does.
56
+ *
57
+ * @RequiresSet @OnHookable @CanHookable
58
+ */
59
+ readonly description: string;
60
+ }
61
+ export type Commands<TEntries extends Record<string, Command> = Record<string, Command>> = {
62
+ type: "commands";
63
+ /**
64
+ * The command entries.
65
+ *
66
+ * To add/remove entries you should {@link addCommand}/{@link removeCommand} or {@link setCommandsProp} with the synthetic `entries@add/remove` properties.
67
+ *
68
+ * The synthetic properties can be hooked into with {@link Manager.hooks}.
69
+ *
70
+ * @RequiresSet @OnHookable @Managed
71
+ */
72
+ entries: TEntries;
73
+ };
74
+ export type RawCommands = Pick<Commands, "entries"> & Partial<Commands>;
75
+ type GetCommandHooks<T extends keyof CommandSetEntries | keyof CommandsSetEntries> = T extends CanHookCommandProps ? Partial<Pick<NonNullable<Manager["hooks"]>, "canSetCommandProp" | "onSetCommandProp">> : T extends OnHookCommandProps ? Partial<Pick<NonNullable<Manager["hooks"]>, "onSetCommandProp">> : T extends CanHookCommandsProps ? Partial<Pick<NonNullable<Manager["hooks"]>, "canSetCommandsProp" | "onSetCommandsProp">> : Partial<Pick<NonNullable<Manager["hooks"]>, "onSetCommandsProp">>;
76
+ type Unmanaged<T extends keyof Command & keyof CommandSetEntries> = {
77
+ val: Command[T];
78
+ manager: never;
79
+ hooks: GetCommandHooks<T>;
80
+ error: never;
81
+ };
82
+ export type CommandSetEntries = {
83
+ condition: Unmanaged<"condition">;
84
+ execute: Unmanaged<"execute">;
85
+ description: Unmanaged<"description">;
86
+ name: {
87
+ val: string;
88
+ manager: Pick<Manager, "commands" | "shortcuts" | "keys"> & PickManager<"options", "stringifier">;
89
+ hooks: GetCommandHooks<"name">;
90
+ error: typeof SHORTCUT_ERROR.COMMAND_IN_USE | typeof SHORTCUT_ERROR.DUPLICATE_COMMAND | typeof SHORTCUT_ERROR.MULTIPLE_ERRORS;
91
+ };
92
+ };
93
+ export type OnHookCommandProps = "condition" | "execute" | "description";
94
+ export type CanHookCommandProps = OnHookCommandProps;
95
+ type BaseCommandsManager = PickManager<"options", "stringifier"> & Record<any, any> & Pick<Manager, "commands">;
96
+ export type CommandsSetEntries = {
97
+ "entries@add": {
98
+ val: Command;
99
+ hooks: GetCommandHooks<`entries@add`>;
100
+ manager: BaseCommandsManager;
101
+ error: typeof SHORTCUT_ERROR.DUPLICATE_COMMAND;
102
+ };
103
+ "entries@remove": {
104
+ val: Command;
105
+ hooks: GetCommandHooks<`entries@remove`>;
106
+ manager: BaseCommandsManager & Pick<Manager, "shortcuts" | "keys">;
107
+ error: typeof SHORTCUT_ERROR.COMMAND_IN_USE | typeof SHORTCUT_ERROR.MISSING;
108
+ };
109
+ };
110
+ export type SyntheticOnHookCommandsProps = "entries@add" | "entries@remove";
111
+ export type CanHookCommandsProps = SyntheticOnHookCommandsProps;
112
+ export type OnHookCommandsProps = SyntheticOnHookCommandsProps;
113
+ export {};
File without changes
@@ -0,0 +1,29 @@
1
+ import type { Context } from "./context.js";
2
+ export type RawCondition = string;
3
+ /**
4
+ * This just describes a condition. No logic to parse/evaluate them is provided and a third party library should be used. The {@link ConditionEvaluator} can then be used to specify how to evaluate them.
5
+ */
6
+ export interface Condition {
7
+ type: "condition";
8
+ /**
9
+ * The main text representation of the condition. Note that this is NOT a unique identifier for conditions and cannot be used to compare them if you are using boolean expressions for your conditions. See {@link Condition.constructor} for an explanation.
10
+ */
11
+ text: string;
12
+ }
13
+ /**
14
+ * Returns whether the condition passed is equal to this one.
15
+ *
16
+ * The default method does a simplistic check of the `text` property for equality. If you override the method you will likely want it to just always return false.
17
+ *
18
+ * Why? Because unless you're using simple single variable conditions that you can presort to make them uniquely identifiable (i.e. not boolean expressions, but something like `!a b !c`), this will return A LOT of false negatives.
19
+ *
20
+ * Why the false negatives? Because two conditions might be functionally equal but have differing representations (e.g: `a && b`, `b && a`). You might think, lets normalize them all, but normalizing boolean expressions (converting them to CNF) can be dangerous with very long expressions because it can take exponential time.
21
+ *
22
+ * Now the main reason for checking the equality of two conditions is to check if two shortcuts might conflict. If we're using boolean expressions it just can't be done safely.
23
+ *
24
+ * This is a personal preference, but if we have a method that gives false negatives it can be confusing that some shortcuts immediately error when added because their conditions are simple, while others don't until triggered. The simpler, more consistent alternative is to only have them error on triggering. Aditionally conflicting conditions can be shown on the keyboard layout when then user picks contexts to check against.
25
+ *
26
+ * Why use the default implementation at all then? Well, shortcuts aren't the only ones that have conditions, commands can too, but unlike shortcuts, usually it's developers who are in charge of assigning a command's condition, and since they are usually simple, it's more possible to make sure the conditions are unique (e.g. tests could enforce they're unique by converting them all to CNF and pre-checking them for equality).
27
+ */
28
+ export type ConditionComparer = (conditionA?: Condition, conditionB?: Condition) => boolean;
29
+ export type ConditionEvaluator<TContext extends Context<any>> = (condition: Condition, context: TContext) => boolean;
File without changes
@@ -0,0 +1,18 @@
1
+ export interface RecursiveRecord {
2
+ [key: string]: any | RecursiveRecord;
3
+ }
4
+ /**
5
+ * # Context
6
+ *
7
+ * Like {@link Condition}, provides a way to describe contexts. How contexts look and work is up to you.
8
+ *
9
+ * Contexts describe the relevant application state. They are what {@link Condition}s are evaluated against.
10
+ *
11
+ * @template TValue **@internal** Captures the type of the context value.
12
+ */
13
+ export type Context<TValue extends object = any> = {
14
+ type: "context";
15
+ /** Where the context object is stored. */
16
+ value: TValue;
17
+ };
18
+ export type RawContext = Pick<Context, "value"> & Partial<Context>;
File without changes
@@ -0,0 +1,186 @@
1
+ import type { EnumLike } from "@alanscodelog/utils";
2
+ import type { Command, Commands } from "./commands.js";
3
+ import type { Key, Keys } from "./keys.js";
4
+ import type { AnyInputEvent } from "./manager.js";
5
+ import type { Shortcut, Shortcuts } from "./shortcuts.js";
6
+ import type { KnownError } from "../helpers/index.js";
7
+ /**
8
+ * All possible errors.
9
+ */
10
+ export declare const SHORTCUT_ERROR: {
11
+ CHORD_W_ONLY_MODIFIERS: "CHORD_W_ONLY_MODIFIERS";
12
+ CHORD_W_MULTIPLE_TRIGGER_KEYS: "CHORD_W_MULTIPLE_TRIGGER_KEYS";
13
+ CHORD_W_MULTIPLE_WHEEL_KEYS: "CHORD_W_MULTIPLE_WHEEL_KEYS";
14
+ CHORD_W_DUPLICATE_KEY: "CHORD_W_DUPLICATE_KEY";
15
+ IMPOSSIBLE_TOGGLE_SEQUENCE: "IMPOSSIBLE_TOGGLE_SEQUENCE";
16
+ MISSING: "MISSING";
17
+ INVALID_VARIANT: "INVALID_VARIANT";
18
+ INVALID_VARIANT_PAIR: "INVALID_VARIANT_PAIR";
19
+ DUPLICATE_KEY: "DUPLICATE_KEY";
20
+ DUPLICATE_COMMAND: "DUPLICATE_COMMAND";
21
+ DUPLICATE_SHORTCUT: "DUPLICATE_SHORTCUT";
22
+ INVALID_SWAP_CHORDS: "INVALID_SWAP_CHORDS";
23
+ CANNOT_SET_WHILE_DISABLED: "CANNOT_SET_WHILE_DISABLED";
24
+ MULTIPLE_MATCHING_SHORTCUTS: "MULTIPLE_MATCHING_SHORTCUTS";
25
+ INCORRECT_TOGGLE_STATE: "INCORRECT_TOGGLE_STATE";
26
+ NO_MATCHING_SHORTCUT: "NO_MATCHING_SHORTCUT";
27
+ UNKNOWN_KEY: "UNKNOWN_KEY";
28
+ UNKNOWN_KEY_ID: "UNKNOWN_KEY_ID";
29
+ UNKNOWN_COMMAND: "UNKNOWN_COMMAND";
30
+ KEY_IN_USE: "KEY_IN_USE";
31
+ COMMAND_IN_USE: "COMMAND_IN_USE";
32
+ UNKNOWN_KEY_EVENT: "UNKNOWN_KEY_EVENT";
33
+ MULTIPLE_ERRORS: "MULTIPLE_ERRORS";
34
+ INVALID_MANAGER: "INVALID_MANAGER";
35
+ };
36
+ export type ShortcutError = EnumLike<typeof SHORTCUT_ERROR>;
37
+ export type ChainError = typeof SHORTCUT_ERROR.UNKNOWN_KEY | typeof SHORTCUT_ERROR.CHORD_W_DUPLICATE_KEY | typeof SHORTCUT_ERROR.CHORD_W_ONLY_MODIFIERS | typeof SHORTCUT_ERROR.CHORD_W_MULTIPLE_TRIGGER_KEYS | typeof SHORTCUT_ERROR.CHORD_W_MULTIPLE_WHEEL_KEYS | typeof SHORTCUT_ERROR.IMPOSSIBLE_TOGGLE_SEQUENCE;
38
+ /** Errors that will throw since they should be caught at production. */
39
+ export declare const TYPE_ERROR: {
40
+ ILLEGAL_OPERATION: "ILLEGAL_OPERATION";
41
+ HOOK_OR_LISTENER_DOES_NOT_EXIST: "HOOK_OR_LISTENER_DOES_NOT_EXIST";
42
+ FILTER_DOES_NOT_EXIST: "FILTER_DOES_NOT_EXIST";
43
+ };
44
+ export type TypeError = EnumLike<typeof TYPE_ERROR>;
45
+ /**
46
+ * Defines the properties attached to each error.
47
+ *
48
+ * Makes it easy to define the properties attached to each error by just allowing passing the error (regardless of error type) as T in [[KnownError]] and [[InternalError]].
49
+ */
50
+ export type ErrorInfo<T extends ShortcutError | TypeError> = T extends ShortcutError ? ERROR_Info[T] : never;
51
+ /** Type multiple {@link KnownError} errors to work like a discriminated union. */
52
+ export type MultipleErrors<T extends ShortcutError | TypeError> = {
53
+ [k in T]: KnownError<k>;
54
+ }[T];
55
+ type ERROR_Info = {
56
+ [SHORTCUT_ERROR.CHORD_W_ONLY_MODIFIERS]: {
57
+ chord: string[];
58
+ i: number;
59
+ keys: string[];
60
+ };
61
+ [SHORTCUT_ERROR.CHORD_W_MULTIPLE_TRIGGER_KEYS]: {
62
+ chord: string[];
63
+ i: number;
64
+ keys: string[];
65
+ };
66
+ [SHORTCUT_ERROR.CHORD_W_MULTIPLE_WHEEL_KEYS]: {
67
+ chord: string[];
68
+ i: number;
69
+ keys: string[];
70
+ };
71
+ [SHORTCUT_ERROR.CHORD_W_DUPLICATE_KEY]: {
72
+ chord: string[];
73
+ i: number;
74
+ keys: string[];
75
+ };
76
+ [SHORTCUT_ERROR.IMPOSSIBLE_TOGGLE_SEQUENCE]: {
77
+ chain: string[][];
78
+ i: number;
79
+ key: Key;
80
+ };
81
+ [SHORTCUT_ERROR.MISSING]: {
82
+ entry: Key | Shortcut | Command | string;
83
+ self: Keys | Shortcuts | Commands;
84
+ };
85
+ [SHORTCUT_ERROR.INVALID_VARIANT]: {
86
+ variants: string[];
87
+ id: string;
88
+ };
89
+ [SHORTCUT_ERROR.INVALID_VARIANT_PAIR]: {
90
+ variants: Key[];
91
+ key: Key;
92
+ otherKey: Key;
93
+ };
94
+ [SHORTCUT_ERROR.DUPLICATE_KEY]: {
95
+ existing: Key;
96
+ self: Keys;
97
+ };
98
+ [SHORTCUT_ERROR.DUPLICATE_SHORTCUT]: {
99
+ existing: Shortcut;
100
+ self: Shortcuts;
101
+ /** If the error is caused by a change, key and value will contain the new key and value. */
102
+ key?: string;
103
+ value?: any;
104
+ };
105
+ [SHORTCUT_ERROR.DUPLICATE_COMMAND]: {
106
+ existing: Command;
107
+ self: Commands;
108
+ };
109
+ [SHORTCUT_ERROR.INVALID_SWAP_CHORDS]: {
110
+ chord: string[][];
111
+ } | {
112
+ chordsA: string[][];
113
+ chordsB: string[][];
114
+ };
115
+ [SHORTCUT_ERROR.CANNOT_SET_WHILE_DISABLED]: {
116
+ key: Key;
117
+ };
118
+ [SHORTCUT_ERROR.MULTIPLE_MATCHING_SHORTCUTS]: {
119
+ shortcuts: Shortcut[];
120
+ };
121
+ [SHORTCUT_ERROR.INCORRECT_TOGGLE_STATE]: {
122
+ key: Key;
123
+ };
124
+ [SHORTCUT_ERROR.NO_MATCHING_SHORTCUT]: {
125
+ chain: string[][];
126
+ };
127
+ [SHORTCUT_ERROR.UNKNOWN_KEY]: {
128
+ shortcut?: Pick<Shortcut, "chain">;
129
+ keys: string[] | Keys;
130
+ };
131
+ [SHORTCUT_ERROR.UNKNOWN_COMMAND]: {
132
+ shortcut?: Pick<Shortcut, "chain" | "command">;
133
+ command: string;
134
+ commands: string[] | Commands;
135
+ };
136
+ [SHORTCUT_ERROR.MULTIPLE_ERRORS]: {
137
+ errors: Error[];
138
+ };
139
+ [SHORTCUT_ERROR.KEY_IN_USE]: {
140
+ inUseShortcuts: Shortcut[];
141
+ };
142
+ [SHORTCUT_ERROR.COMMAND_IN_USE]: {
143
+ inUseShortcuts: Shortcut[];
144
+ };
145
+ [SHORTCUT_ERROR.UNKNOWN_KEY_EVENT]: {
146
+ e: AnyInputEvent;
147
+ button?: string;
148
+ code?: string;
149
+ key?: string;
150
+ deltaY?: number | string;
151
+ };
152
+ [SHORTCUT_ERROR.UNKNOWN_KEY_ID]: {
153
+ id: string;
154
+ };
155
+ [SHORTCUT_ERROR.INVALID_MANAGER]: {
156
+ keys: string[];
157
+ };
158
+ };
159
+ export declare const MOUSE: {
160
+ R: "R";
161
+ M: "M";
162
+ L: "L";
163
+ BACK: "BACK";
164
+ FORWARD: "FORWARD";
165
+ };
166
+ export type Mouse = EnumLike<typeof MOUSE>;
167
+ export declare const WHEEL: {
168
+ down: "down";
169
+ up: "up";
170
+ };
171
+ export type Wheel = EnumLike<typeof WHEEL>;
172
+ export declare const KEY_SORT_POS: {
173
+ mod: number;
174
+ modmouse: number;
175
+ modwheel: number;
176
+ modtoggle: number;
177
+ modtogglemouse: number;
178
+ modtogglewheel: number;
179
+ normal: number;
180
+ mouse: number;
181
+ wheel: number;
182
+ toggle: number;
183
+ togglemouse: number;
184
+ togglewheel: number;
185
+ };
186
+ export {};