@baleada/logic 0.23.2 → 0.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import BezierEasing from 'bezier-easing';
2
2
  import { mix } from '@snigo.dev/color';
3
- import { pipe, concat, toArray, filter, map, reduce, slice, sort, unique, find, findIndex, join, at, includes, some, every, flatMap, reverse as reverse$1 } from 'lazy-collections';
3
+ import { pipe, unique, map, toArray, every, some, includes, concat, filter, reduce, slice, sort, find, findIndex, join, at, flatMap, reverse as reverse$1 } from 'lazy-collections';
4
4
  import { getStroke } from 'perfect-freehand';
5
5
  import polygonClipping from 'polygon-clipping';
6
6
  import ky from 'ky';
@@ -11,6 +11,202 @@ import { dequal } from 'dequal';
11
11
  import slugify from '@sindresorhus/slugify';
12
12
  import clsx from 'clsx';
13
13
 
14
+ function fromComboToAliases(combo) {
15
+ const delimiter = "+";
16
+ return pipe(
17
+ unique(),
18
+ map((name) => name === "" ? delimiter : name.toLowerCase()),
19
+ toArray()
20
+ )(combo.split(delimiter));
21
+ }
22
+
23
+ function fromAliasToDownKeys(alias) {
24
+ if (alias in keysByAlias) {
25
+ return [{ key: keysByAlias[alias] }];
26
+ }
27
+ if (alias in keyStatusKeysByAlias)
28
+ return keyStatusKeysByAlias[alias];
29
+ return [{
30
+ code: (() => {
31
+ if (letterRE.test(alias))
32
+ return `Key${alias.toUpperCase()}`;
33
+ if (digitRE.test(alias))
34
+ return `Digit${alias}`;
35
+ if (functionRE.test(alias))
36
+ return alias.toUpperCase();
37
+ return "unsupported";
38
+ })()
39
+ }];
40
+ }
41
+ const digitRE = /^[0-9]$/;
42
+ const letterRE = /^[a-zA-Z]$/;
43
+ const functionRE = /^[fF][0-9]{1,2}$/;
44
+ const keyStatusKeysByAlias = {
45
+ "`": [{ code: "Backquote" }],
46
+ "~": [{ code: "Backquote" }, { key: "Shift" }],
47
+ "-": [{ code: "Minus" }],
48
+ _: [{ code: "Minus" }, { key: "Shift" }],
49
+ "=": [{ code: "Equal" }],
50
+ "+": [{ code: "Equal" }, { key: "Shift" }],
51
+ "[": [{ code: "BracketLeft" }],
52
+ "{": [{ code: "BracketLeft" }, { key: "Shift" }],
53
+ "]": [{ code: "BracketRight" }],
54
+ "}": [{ code: "BracketRight" }, { key: "Shift" }],
55
+ "\\": [{ code: "Backslash" }],
56
+ "|": [{ code: "Backslash" }, { key: "Shift" }],
57
+ ";": [{ code: "Semicolon" }],
58
+ ":": [{ code: "Semicolon" }, { key: "Shift" }],
59
+ "'": [{ code: "Quote" }],
60
+ '"': [{ code: "Quote" }, { key: "Shift" }],
61
+ ",": [{ code: "Comma" }],
62
+ "<": [{ code: "Comma" }, { key: "Shift" }],
63
+ ".": [{ code: "Period" }],
64
+ ">": [{ code: "Period" }, { key: "Shift" }],
65
+ "/": [{ code: "Slash" }],
66
+ "?": [{ code: "Slash" }, { key: "Shift" }],
67
+ "!": [{ code: "Digit1" }, { key: "Shift" }],
68
+ "@": [{ code: "Digit2" }, { key: "Shift" }],
69
+ "#": [{ code: "Digit3" }, { key: "Shift" }],
70
+ $: [{ code: "Digit4" }, { key: "Shift" }],
71
+ "%": [{ code: "Digit5" }, { key: "Shift" }],
72
+ "^": [{ code: "Digit6" }, { key: "Shift" }],
73
+ "&": [{ code: "Digit7" }, { key: "Shift" }],
74
+ "*": [{ code: "Digit8" }, { key: "Shift" }],
75
+ "(": [{ code: "Digit9" }, { key: "Shift" }],
76
+ ")": [{ code: "Digit0" }, { key: "Shift" }],
77
+ up: [{ code: "ArrowUp" }],
78
+ down: [{ code: "ArrowDown" }],
79
+ left: [{ code: "ArrowLeft" }],
80
+ right: [{ code: "ArrowRight" }],
81
+ enter: [{ code: "Enter" }],
82
+ space: [{ code: "Space" }],
83
+ tab: [{ code: "Tab" }],
84
+ esc: [{ code: "Escape" }],
85
+ backspace: [{ code: "Backspace" }],
86
+ delete: [{ code: "Delete" }],
87
+ home: [{ code: "Home" }],
88
+ end: [{ code: "End" }],
89
+ pagedown: [{ code: "PageDown" }],
90
+ pageup: [{ code: "PageUp" }],
91
+ capslock: [{ code: "CapsLock" }],
92
+ camera: [{ code: "Camera" }]
93
+ };
94
+ const keysByAlias = {
95
+ alt: "Alt",
96
+ opt: "Alt",
97
+ option: "Alt",
98
+ ctrl: "Control",
99
+ control: "Control",
100
+ meta: "Meta",
101
+ cmd: "Meta",
102
+ command: "Meta",
103
+ shift: "Shift"
104
+ };
105
+
106
+ const defaultOptions$m = {
107
+ toDownKeys: (alias) => fromAliasToDownKeys(alias)
108
+ };
109
+ const createPredicateKeycomboDown = (keycombo, options = {}) => {
110
+ const { toDownKeys } = { ...defaultOptions$m, ...options }, downKeys = pipe(
111
+ fromComboToAliases,
112
+ map(toDownKeys)
113
+ )(keycombo);
114
+ return (statuses) => {
115
+ const predicateAliasEntriesDown = every(
116
+ (key) => statuses.toValue(key) === "down"
117
+ );
118
+ return every(predicateAliasEntriesDown)(downKeys);
119
+ };
120
+ };
121
+
122
+ function fromEventToAliases(event) {
123
+ if (event.shiftKey && event.code in aliasesByShiftCode) {
124
+ return [aliasesByShiftCode[event.code]];
125
+ }
126
+ if (event.key in aliasListsByModifier) {
127
+ return aliasListsByModifier[event.key];
128
+ }
129
+ return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
130
+ }
131
+ const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
132
+ const aliasesByCode = {
133
+ Backquote: "`",
134
+ Minus: "-",
135
+ Equal: "=",
136
+ BracketLeft: "[",
137
+ BracketRight: "]",
138
+ Backslash: "\\",
139
+ Semicolon: ";",
140
+ Quote: "'",
141
+ Comma: ",",
142
+ Period: ".",
143
+ Slash: "/",
144
+ ArrowUp: "up",
145
+ ArrowDown: "down",
146
+ ArrowLeft: "left",
147
+ ArrowRight: "right",
148
+ Enter: "enter",
149
+ Space: "space",
150
+ Tab: "tab",
151
+ Escape: "esc",
152
+ Backspace: "backspace",
153
+ Delete: "delete",
154
+ Home: "home",
155
+ End: "end",
156
+ PageDown: "pagedown",
157
+ PageUp: "pageup",
158
+ CapsLock: "capslock",
159
+ Camera: "camera"
160
+ };
161
+ const aliasesByShiftCode = {
162
+ Backquote: "~",
163
+ Minus: "_",
164
+ Equal: "+",
165
+ BracketLeft: "{",
166
+ BracketRight: "}",
167
+ Backslash: "|",
168
+ Semicolon: ":",
169
+ Quote: '"',
170
+ Comma: "<",
171
+ Period: ">",
172
+ Slash: "?",
173
+ Digit1: "!",
174
+ Digit2: "@",
175
+ Digit3: "#",
176
+ Digit4: "$",
177
+ Digit5: "%",
178
+ Digit6: "^",
179
+ Digit7: "&",
180
+ Digit8: "*",
181
+ Digit9: "(",
182
+ Digit0: ")"
183
+ };
184
+ const aliasListsByModifier = {
185
+ Alt: ["alt", "option", "opt"],
186
+ Control: ["control", "ctrl"],
187
+ Meta: ["meta", "command", "cmd"],
188
+ Shift: ["shift"]
189
+ };
190
+
191
+ const defaultOptions$l = {
192
+ toDownKeys: (alias) => fromAliasToDownKeys(alias),
193
+ toAliases: (event) => fromEventToAliases(event)
194
+ };
195
+ const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
196
+ const { toDownKeys, toAliases } = { ...defaultOptions$l, ...options }, aliases = fromComboToAliases(keycombo), downKeys = map(toDownKeys)(aliases);
197
+ return (statuses) => {
198
+ const predicateAliasDown = every(
199
+ (key) => statuses.toValue(key) === "down"
200
+ );
201
+ return every(predicateAliasDown)(downKeys) && every(
202
+ ([key, value]) => value === "up" || pipe(
203
+ toAliases,
204
+ some((alias) => includes(alias)(aliases))
205
+ )(key)
206
+ )(statuses.toEntries());
207
+ };
208
+ };
209
+
14
210
  function createClone() {
15
211
  return (any) => {
16
212
  return klona(any);
@@ -278,7 +474,7 @@ function createRename(from, to) {
278
474
  };
279
475
  }
280
476
 
281
- const defaultOptions$m = {
477
+ const defaultOptions$k = {
282
478
  elementIsCandidate: false,
283
479
  // Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
284
480
  tabbableSelector: join(':not([hidden]):not([tabindex="-1"]),')([
@@ -299,7 +495,7 @@ const defaultOptions$m = {
299
495
  ])
300
496
  };
301
497
  function createFocusable(order, options = {}) {
302
- const { elementIsCandidate, tabbableSelector } = { ...defaultOptions$m, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
498
+ const { elementIsCandidate, tabbableSelector } = { ...defaultOptions$k, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
303
499
  return (element) => {
304
500
  if (elementIsCandidate && predicateFocusable(element))
305
501
  return element;
@@ -734,12 +930,12 @@ function createList() {
734
930
  return (...classValues) => clsx(...classValues);
735
931
  }
736
932
 
737
- const defaultOptions$l = {
933
+ const defaultOptions$j = {
738
934
  toId: (node) => node.id,
739
935
  toChildren: (node) => node.children
740
936
  };
741
937
  function createToGraph(options = {}) {
742
- const { toId, toChildren } = { ...defaultOptions$l, ...options };
938
+ const { toId, toChildren } = { ...defaultOptions$j, ...options };
743
939
  return function* (tree) {
744
940
  const root = tree[0], rootId = toId(root);
745
941
  function* toPair(node, id) {
@@ -758,34 +954,56 @@ function createToGraph(options = {}) {
758
954
  };
759
955
  }
760
956
 
761
- const defaultOptions$k = {
762
- toKey: (alias) => fromAliasToKeyStatusKey(alias)
957
+ const defaultOptions$i = {
958
+ toDownKeys: (alias) => fromAliasToDownKeys(alias),
959
+ toAliases: (event) => fromEventToAliases(event)
763
960
  };
764
- const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
765
- const { toKey } = { ...defaultOptions$k, ...options }, keys = pipe(
766
- fromComboToAliases,
767
- map(toKey)
768
- )(keycombo);
961
+ const createPredicateKeycomboMatch = (keycombo, options = {}) => {
962
+ const { toDownKeys, toAliases } = { ...defaultOptions$i, ...options }, aliases = fromComboToAliases(keycombo), downKeys = createMap(toDownKeys)(aliases), implicitModifierAliases = (() => {
963
+ const implicitModifierAliases2 = [];
964
+ for (const aliasDownKeys of downKeys) {
965
+ for (const { key } of aliasDownKeys) {
966
+ if (includes(key)(modifiers))
967
+ implicitModifierAliases2.push(key.toLowerCase());
968
+ }
969
+ }
970
+ return implicitModifierAliases2;
971
+ })();
769
972
  return (event) => {
770
- const { toValue, set } = createKeyStatuses();
771
- set(fromEventToKeyStatusKey(event), "down");
973
+ const statuses = createKeyStatuses(), predicateAliasDown = every(
974
+ (key) => statuses.toValue(key) === "down"
975
+ );
976
+ statuses.set(fromEventToKeyStatusKey(event), "down");
772
977
  for (const modifier of modifiers) {
773
978
  if (event[`${modifier.toLowerCase()}Key`])
774
- set({ key: modifier }, "down");
979
+ statuses.set({ key: modifier }, "down");
775
980
  }
776
- return every(pipe(
777
- toValue,
778
- predicateDown
779
- ))(keys);
981
+ const events = createMap(
982
+ ([key]) => {
983
+ const e = { ...key };
984
+ for (const modifier of modifiers) {
985
+ e[`${modifier.toLowerCase()}Key`] = event[`${modifier.toLowerCase()}Key`];
986
+ }
987
+ return e;
988
+ }
989
+ )(statuses.toEntries());
990
+ return every(predicateAliasDown)(downKeys) && every(
991
+ (e) => pipe(
992
+ toAliases,
993
+ some(
994
+ (alias) => includes(alias)(aliases) || includes(alias)(implicitModifierAliases)
995
+ )
996
+ )(e)
997
+ )(events);
780
998
  };
781
999
  };
782
1000
 
783
- const defaultOptions$j = {
1001
+ const defaultOptions$h = {
784
1002
  initial: [],
785
1003
  createPredicateKey: (query) => (candidate) => query === candidate
786
1004
  };
787
1005
  function createAssociativeArray(options = {}) {
788
- const { initial, createPredicateKey } = { ...defaultOptions$j, ...options }, entries = [...initial];
1006
+ const { initial, createPredicateKey } = { ...defaultOptions$h, ...options }, entries = [...initial];
789
1007
  const toValue = (key) => {
790
1008
  const predicateKey = createPredicateKey(key);
791
1009
  return find(
@@ -846,22 +1064,22 @@ function createAssociativeArray(options = {}) {
846
1064
  };
847
1065
  }
848
1066
 
849
- const defaultOptions$i = {
1067
+ const defaultOptions$g = {
850
1068
  minDuration: 0,
851
1069
  preventsDefaultUnlessDenied: true,
852
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1070
+ toDownKeys: (alias) => fromAliasToDownKeys(alias),
853
1071
  toAliases: (event) => fromEventToAliases(event)
854
1072
  };
855
1073
  function createKeypress(keycomboOrKeycombos, options = {}) {
856
1074
  const {
857
1075
  minDuration,
858
1076
  preventsDefaultUnlessDenied,
859
- toKey,
1077
+ toDownKeys,
860
1078
  toAliases,
861
1079
  onDown,
862
1080
  onUp,
863
1081
  onVisibilitychange
864
- } = { ...defaultOptions$i, ...options }, {
1082
+ } = { ...defaultOptions$g, ...options }, {
865
1083
  matchPredicatesByKeycombo,
866
1084
  getDownCombos,
867
1085
  predicateValid,
@@ -870,7 +1088,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
870
1088
  } = createKeyState({
871
1089
  keycomboOrKeycombos,
872
1090
  unsupportedAliases: unsupportedAliases$2,
873
- toKey,
1091
+ toDownKeys,
874
1092
  toAliases,
875
1093
  getRequest: () => request
876
1094
  });
@@ -969,22 +1187,22 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
969
1187
  const unsupportedAliases$2 = ["meta", "command", "cmd"];
970
1188
  const unsupportedKeys$2 = ["Meta"];
971
1189
 
972
- const defaultOptions$h = {
1190
+ const defaultOptions$f = {
973
1191
  minDuration: 0,
974
1192
  preventsDefaultUnlessDenied: true,
975
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1193
+ toDownKeys: (alias) => fromAliasToDownKeys(alias),
976
1194
  toAliases: (event) => fromEventToAliases(event)
977
1195
  };
978
1196
  function createKeyrelease(keycomboOrKeycombos, options = {}) {
979
1197
  const {
980
1198
  minDuration,
981
1199
  preventsDefaultUnlessDenied,
982
- toKey,
1200
+ toDownKeys,
983
1201
  toAliases,
984
1202
  onDown,
985
1203
  onUp,
986
1204
  onVisibilitychange
987
- } = { ...defaultOptions$h, ...options }, {
1205
+ } = { ...defaultOptions$f, ...options }, {
988
1206
  matchPredicatesByKeycombo,
989
1207
  getDownCombos,
990
1208
  predicateValid,
@@ -993,7 +1211,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
993
1211
  } = createKeyState({
994
1212
  keycomboOrKeycombos,
995
1213
  unsupportedAliases: unsupportedAliases$1,
996
- toKey,
1214
+ toDownKeys,
997
1215
  toAliases,
998
1216
  getRequest: () => request
999
1217
  });
@@ -1095,12 +1313,12 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1095
1313
  const unsupportedAliases$1 = ["meta", "command", "cmd"];
1096
1314
  const unsupportedKeys$1 = ["Meta"];
1097
1315
 
1098
- const defaultOptions$g = {
1316
+ const defaultOptions$e = {
1099
1317
  minDuration: 0,
1100
1318
  maxInterval: 5e3,
1101
1319
  // VS Code default
1102
1320
  preventsDefaultUnlessDenied: true,
1103
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1321
+ toDownKeys: (alias) => fromAliasToDownKeys(alias),
1104
1322
  toAliases: (event) => fromEventToAliases(event)
1105
1323
  };
1106
1324
  function createKeychord(keychord, options = {}) {
@@ -1108,15 +1326,15 @@ function createKeychord(keychord, options = {}) {
1108
1326
  minDuration,
1109
1327
  maxInterval,
1110
1328
  preventsDefaultUnlessDenied,
1111
- toKey,
1329
+ toDownKeys,
1112
1330
  toAliases,
1113
1331
  onDown,
1114
1332
  onUp,
1115
1333
  onVisibilitychange
1116
- } = { ...defaultOptions$g, ...options }, narrowedKeychord = keychord.split(" "), keyStates = createMap((keycombo) => createKeyState({
1334
+ } = { ...defaultOptions$e, ...options }, narrowedKeychord = keychord.split(" "), keyStates = createMap((keycombo) => createKeyState({
1117
1335
  keycomboOrKeycombos: keycombo,
1118
1336
  unsupportedAliases,
1119
- toKey,
1337
+ toDownKeys,
1120
1338
  toAliases,
1121
1339
  getRequest: () => request
1122
1340
  }))(narrowedKeychord), localStatuses = createMap(
@@ -1261,7 +1479,7 @@ function createKonami(options = {}) {
1261
1479
  return createKeychord("up up down down left right left right b a enter", options);
1262
1480
  }
1263
1481
 
1264
- const defaultOptions$f = {
1482
+ const defaultOptions$d = {
1265
1483
  minDuration: 0,
1266
1484
  minDistance: 0,
1267
1485
  getMousemoveTarget: (event) => event.target
@@ -1275,7 +1493,7 @@ function createMousepress(options = {}) {
1275
1493
  onLeave,
1276
1494
  onMove,
1277
1495
  onUp
1278
- } = { ...defaultOptions$f, ...options }, cleanup = (event) => {
1496
+ } = { ...defaultOptions$d, ...options }, cleanup = (event) => {
1279
1497
  window.cancelAnimationFrame(request);
1280
1498
  getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1281
1499
  };
@@ -1335,7 +1553,7 @@ function createMousepress(options = {}) {
1335
1553
  };
1336
1554
  }
1337
1555
 
1338
- const defaultOptions$e = {
1556
+ const defaultOptions$c = {
1339
1557
  minDuration: 0,
1340
1558
  minDistance: 0,
1341
1559
  minVelocity: 0,
@@ -1351,7 +1569,7 @@ function createMouserelease(options = {}) {
1351
1569
  onLeave,
1352
1570
  onMove,
1353
1571
  onUp
1354
- } = { ...defaultOptions$e, ...options }, cleanup = (event) => {
1572
+ } = { ...defaultOptions$c, ...options }, cleanup = (event) => {
1355
1573
  window.cancelAnimationFrame(request);
1356
1574
  getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1357
1575
  };
@@ -1409,7 +1627,7 @@ function createMouserelease(options = {}) {
1409
1627
  };
1410
1628
  }
1411
1629
 
1412
- const defaultOptions$d = {
1630
+ const defaultOptions$b = {
1413
1631
  minDuration: 0,
1414
1632
  minDistance: 0
1415
1633
  };
@@ -1421,7 +1639,7 @@ function createTouchpress(options = {}) {
1421
1639
  onCancel,
1422
1640
  onMove,
1423
1641
  onEnd
1424
- } = { ...defaultOptions$d, ...options }, cleanup = () => {
1642
+ } = { ...defaultOptions$b, ...options }, cleanup = () => {
1425
1643
  window.cancelAnimationFrame(request);
1426
1644
  };
1427
1645
  let request;
@@ -1482,7 +1700,7 @@ function createTouchpress(options = {}) {
1482
1700
  };
1483
1701
  }
1484
1702
 
1485
- const defaultOptions$c = {
1703
+ const defaultOptions$a = {
1486
1704
  minDuration: 0,
1487
1705
  minDistance: 0,
1488
1706
  minVelocity: 0
@@ -1496,7 +1714,7 @@ function createTouchrelease(options = {}) {
1496
1714
  onCancel,
1497
1715
  onMove,
1498
1716
  onEnd
1499
- } = { ...defaultOptions$c, ...options }, cleanup = () => {
1717
+ } = { ...defaultOptions$a, ...options }, cleanup = () => {
1500
1718
  window.cancelAnimationFrame(request);
1501
1719
  };
1502
1720
  let request;
@@ -1563,12 +1781,12 @@ function createTouchrelease(options = {}) {
1563
1781
  };
1564
1782
  }
1565
1783
 
1566
- const defaultOptions$b = {
1784
+ const defaultOptions$9 = {
1567
1785
  initial: []
1568
1786
  };
1569
1787
  function createKeyStatuses(options = {}) {
1570
1788
  return createAssociativeArray({
1571
- ...defaultOptions$b,
1789
+ ...defaultOptions$9,
1572
1790
  ...options,
1573
1791
  createPredicateKey: (query) => (key) => {
1574
1792
  for (const prop in query) {
@@ -1580,214 +1798,14 @@ function createKeyStatuses(options = {}) {
1580
1798
  }
1581
1799
  });
1582
1800
  }
1583
- function predicateDown(status) {
1584
- return status === "down";
1585
- }
1586
1801
  function predicateSomeKeyDown(statuses) {
1587
1802
  return includes("down")(statuses.toValues());
1588
1803
  }
1589
1804
 
1590
- function fromComboToAliases(combo) {
1591
- const delimiter = "+";
1592
- return pipe(
1593
- unique(),
1594
- map((name) => name === "" ? delimiter : name.toLowerCase()),
1595
- toArray()
1596
- )(combo.split(delimiter));
1597
- }
1598
-
1599
- function fromAliasToKeyStatusKey(alias) {
1600
- if (alias in keysByAlias) {
1601
- return { key: keysByAlias[alias] };
1602
- }
1603
- return {
1604
- code: (() => {
1605
- if (alias in codesByAlias)
1606
- return codesByAlias[alias];
1607
- if (letterRE.test(alias))
1608
- return `Key${alias.toUpperCase()}`;
1609
- if (digitRE.test(alias))
1610
- return `Digit${alias}`;
1611
- if (functionRE.test(alias))
1612
- return alias.toUpperCase();
1613
- return "unsupported";
1614
- })()
1615
- };
1616
- }
1617
- const digitRE = /^[0-9]$/;
1618
- const letterRE = /^[a-zA-Z]$/;
1619
- const functionRE = /^[fF][0-9]{1,2}$/;
1620
- const codesByAlias = {
1621
- "`": "Backquote",
1622
- "~": "Backquote",
1623
- "-": "Minus",
1624
- _: "Minus",
1625
- "=": "Equal",
1626
- "+": "Equal",
1627
- "[": "BracketLeft",
1628
- "{": "BracketLeft",
1629
- "]": "BracketRight",
1630
- "}": "BracketRight",
1631
- "\\": "Backslash",
1632
- "|": "Backslash",
1633
- ";": "Semicolon",
1634
- ":": "Semicolon",
1635
- "'": "Quote",
1636
- '"': "Quote",
1637
- ",": "Comma",
1638
- "<": "Comma",
1639
- ".": "Period",
1640
- ">": "Period",
1641
- "/": "Slash",
1642
- "?": "Slash",
1643
- "!": "Digit1",
1644
- "@": "Digit2",
1645
- "#": "Digit3",
1646
- $: "Digit4",
1647
- "%": "Digit5",
1648
- "^": "Digit6",
1649
- "&": "Digit7",
1650
- "*": "Digit8",
1651
- "(": "Digit9",
1652
- ")": "Digit0",
1653
- up: "ArrowUp",
1654
- down: "ArrowDown",
1655
- left: "ArrowLeft",
1656
- right: "ArrowRight",
1657
- enter: "Enter",
1658
- space: "Space",
1659
- tab: "Tab",
1660
- esc: "Escape",
1661
- backspace: "Backspace",
1662
- delete: "Delete",
1663
- home: "Home",
1664
- end: "End",
1665
- pagedown: "PageDown",
1666
- pageup: "PageUp",
1667
- capslock: "CapsLock",
1668
- camera: "Camera"
1669
- };
1670
- const keysByAlias = {
1671
- alt: "Alt",
1672
- opt: "Alt",
1673
- option: "Alt",
1674
- ctrl: "Control",
1675
- control: "Control",
1676
- meta: "Meta",
1677
- cmd: "Meta",
1678
- command: "Meta",
1679
- shift: "Shift"
1680
- };
1681
-
1682
- const defaultOptions$a = {
1683
- toKey: (alias) => fromAliasToKeyStatusKey(alias)
1684
- };
1685
- const createPredicateKeycomboDown = (keycombo, options = {}) => {
1686
- const { toKey } = { ...defaultOptions$a, ...options }, keys = pipe(
1687
- fromComboToAliases,
1688
- map(toKey)
1689
- )(keycombo);
1690
- return (statuses) => {
1691
- const { toValue } = statuses;
1692
- return every(pipe(
1693
- toValue,
1694
- predicateDown
1695
- ))(keys);
1696
- };
1697
- };
1698
-
1699
- function fromEventToAliases(event) {
1700
- if (event.shiftKey && event.code in aliasesByShiftCode) {
1701
- return [aliasesByShiftCode[event.code]];
1702
- }
1703
- if (event.key in aliasListsByModifier) {
1704
- return aliasListsByModifier[event.key];
1705
- }
1706
- return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
1707
- }
1708
- const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
1709
- const aliasesByCode = {
1710
- Backquote: "`",
1711
- Minus: "-",
1712
- Equal: "=",
1713
- BracketLeft: "[",
1714
- BracketRight: "]",
1715
- Backslash: "\\",
1716
- Semicolon: ";",
1717
- Quote: "'",
1718
- Comma: ",",
1719
- Period: ".",
1720
- Slash: "/",
1721
- ArrowUp: "up",
1722
- ArrowDown: "down",
1723
- ArrowLeft: "left",
1724
- ArrowRight: "right",
1725
- Enter: "enter",
1726
- Space: "space",
1727
- Tab: "tab",
1728
- Escape: "esc",
1729
- Backspace: "backspace",
1730
- Delete: "delete",
1731
- Home: "home",
1732
- End: "end",
1733
- PageDown: "pagedown",
1734
- PageUp: "pageup",
1735
- CapsLock: "capslock",
1736
- Camera: "camera"
1737
- };
1738
- const aliasesByShiftCode = {
1739
- Backquote: "~",
1740
- Minus: "_",
1741
- Equal: "+",
1742
- BracketLeft: "{",
1743
- BracketRight: "}",
1744
- Backslash: "|",
1745
- Semicolon: ":",
1746
- Quote: '"',
1747
- Comma: "<",
1748
- Period: ">",
1749
- Slash: "?",
1750
- Digit1: "!",
1751
- Digit2: "@",
1752
- Digit3: "#",
1753
- Digit4: "$",
1754
- Digit5: "%",
1755
- Digit6: "^",
1756
- Digit7: "&",
1757
- Digit8: "*",
1758
- Digit9: "(",
1759
- Digit0: ")"
1760
- };
1761
- const aliasListsByModifier = {
1762
- Alt: ["alt", "option", "opt"],
1763
- Control: ["control", "ctrl"],
1764
- Meta: ["meta", "command", "cmd"],
1765
- Shift: ["shift"]
1766
- };
1767
-
1768
- const defaultOptions$9 = {
1769
- toKey: (alias) => fromAliasToKeyStatusKey(alias),
1770
- toAliases: (event) => fromEventToAliases(event)
1771
- };
1772
- const createPredicateKeycomboMatch = (keycombo, options = {}) => {
1773
- const { toKey, toAliases } = { ...defaultOptions$9, ...options }, aliases = fromComboToAliases(keycombo), keys = map(toKey)(aliases);
1774
- return (statuses) => {
1775
- const { toValue } = statuses;
1776
- return every(pipe(
1777
- toValue,
1778
- predicateDown
1779
- ))(keys) && every(
1780
- ([key, value]) => value === "up" || some(
1781
- (alias) => includes(alias)(aliases)
1782
- )(toAliases(key))
1783
- )(statuses.toEntries());
1784
- };
1785
- };
1786
-
1787
1805
  function createKeyState({
1788
1806
  keycomboOrKeycombos,
1789
1807
  unsupportedAliases,
1790
- toKey,
1808
+ toDownKeys,
1791
1809
  toAliases,
1792
1810
  getRequest
1793
1811
  }) {
@@ -1795,7 +1813,7 @@ function createKeyState({
1795
1813
  (keycombo) => !some(
1796
1814
  (alias) => includes(alias)(unsupportedAliases)
1797
1815
  )(fromComboToAliases(keycombo))
1798
- )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = { toKey }, downPredicatesByKeycombo = (() => {
1816
+ )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = { toDownKeys }, downPredicatesByKeycombo = (() => {
1799
1817
  const predicates = [];
1800
1818
  for (const keycombo of narrowedKeycombos) {
1801
1819
  predicates.push([
@@ -1810,7 +1828,7 @@ function createKeyState({
1810
1828
  })(), createPredicateKeycomboMatchOptions = { ...createPredicateKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
1811
1829
  const predicates = {};
1812
1830
  for (const keycombo of narrowedKeycombos) {
1813
- predicates[keycombo] = createPredicateKeycomboMatch(
1831
+ predicates[keycombo] = createPredicateKeycomboMatch$1(
1814
1832
  keycombo,
1815
1833
  createPredicateKeycomboMatchOptions
1816
1834
  );
@@ -4977,4 +4995,4 @@ class Storeable {
4977
4995
  }
4978
4996
  }
4979
4997
 
4980
- export { Animateable, Broadcastable, Compareable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createAssociativeArray, createPredicateAncestor$1 as createAsyncDirectedAcyclicPredicateAncestor, createToCommonAncestors$1 as createAsyncDirectedAcyclicToCommonAncestors, createToLayers as createAsyncDirectedAcyclicToLayers, createToNodeSteps$1 as createAsyncDirectedAcyclicToNodeSteps, createToPath$1 as createAsyncDirectedAcyclicToPath, createToSteps$1 as createAsyncDirectedAcyclicToSteps, createToTree$1 as createAsyncDirectedAcyclicToTree, createClamp, createClip, createClone, createConcat, createPredicateAncestor as createDecisionTreePredicateAncestor, createToCommonAncestors as createDecisionTreeToCommonAncestors, createToNodeSteps as createDecisionTreeToNodeSteps, createToPath as createDecisionTreeToPath, createToSteps as createDecisionTreeToSteps, createToTree as createDecisionTreeToTree, createDetermine, createPredicateAncestor$2 as createDirectedAcyclicPredicateAncestor, createToCommonAncestors$2 as createDirectedAcyclicToCommonAncestors, createToLayers$1 as createDirectedAcyclicToLayers, createToNodeSteps$2 as createDirectedAcyclicToNodeSteps, createToPath$2 as createDirectedAcyclicToPath, createToRoots as createDirectedAcyclicToRoots, createToSteps$2 as createDirectedAcyclicToSteps, createToTree$2 as createDirectedAcyclicToTree, createEntries, createEqual, createEvery, createFilter, createFilterAsync, createFindAsync, createFindIndexAsync, createFocusable, createForEachAsync, createInsert, createKeychord, createKeypress, createKeyrelease, createKeys, createKonami, createList, createMap, createMapAsync, createMousepress, createMouserelease, createPredicateKeycomboMatch$1 as createPredicateKeycomboMatch, createPredicateRoot, createReduce, createReduceAsync, createRemove, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSome, createSort, createSwap, createToGraph, createToIncoming, createToIndegree, createToOutdegree, createToOutgoing, createTouchpress, createTouchrelease, createFind as createTreeFind, createUnique, defineAssociativeArrayEntries, defineAsyncGraph, defineAsyncGraphEdge, defineAsyncGraphEdges, defineGraph, defineGraphEdge, defineGraphEdges, defineGraphNode, defineGraphNodes, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
4998
+ export { Animateable, Broadcastable, Compareable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createAssociativeArray, createPredicateAncestor$1 as createAsyncDirectedAcyclicPredicateAncestor, createToCommonAncestors$1 as createAsyncDirectedAcyclicToCommonAncestors, createToLayers as createAsyncDirectedAcyclicToLayers, createToNodeSteps$1 as createAsyncDirectedAcyclicToNodeSteps, createToPath$1 as createAsyncDirectedAcyclicToPath, createToSteps$1 as createAsyncDirectedAcyclicToSteps, createToTree$1 as createAsyncDirectedAcyclicToTree, createClamp, createClip, createClone, createConcat, createPredicateAncestor as createDecisionTreePredicateAncestor, createToCommonAncestors as createDecisionTreeToCommonAncestors, createToNodeSteps as createDecisionTreeToNodeSteps, createToPath as createDecisionTreeToPath, createToSteps as createDecisionTreeToSteps, createToTree as createDecisionTreeToTree, createDetermine, createPredicateAncestor$2 as createDirectedAcyclicPredicateAncestor, createToCommonAncestors$2 as createDirectedAcyclicToCommonAncestors, createToLayers$1 as createDirectedAcyclicToLayers, createToNodeSteps$2 as createDirectedAcyclicToNodeSteps, createToPath$2 as createDirectedAcyclicToPath, createToRoots as createDirectedAcyclicToRoots, createToSteps$2 as createDirectedAcyclicToSteps, createToTree$2 as createDirectedAcyclicToTree, createEntries, createEqual, createEvery, createFilter, createFilterAsync, createFindAsync, createFindIndexAsync, createFocusable, createForEachAsync, createInsert, createKeychord, createKeypress, createKeyrelease, createKeys, createKonami, createList, createMap, createMapAsync, createMousepress, createMouserelease, createPredicateKeycomboMatch, createPredicateRoot, createReduce, createReduceAsync, createRemove, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSome, createSort, createSwap, createToGraph, createToIncoming, createToIndegree, createToOutdegree, createToOutgoing, createTouchpress, createTouchrelease, createFind as createTreeFind, createUnique, defineAssociativeArrayEntries, defineAsyncGraph, defineAsyncGraphEdge, defineAsyncGraphEdges, defineGraph, defineGraphEdge, defineGraphEdges, defineGraphNode, defineGraphNodes, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };