@baleada/logic 0.23.3 → 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.cjs +267 -251
- package/lib/index.d.ts +5 -5
- package/lib/index.js +268 -252
- package/package.json +1 -1
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,
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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,36 +954,56 @@ function createToGraph(options = {}) {
|
|
|
758
954
|
};
|
|
759
955
|
}
|
|
760
956
|
|
|
761
|
-
const defaultOptions$
|
|
762
|
-
|
|
957
|
+
const defaultOptions$i = {
|
|
958
|
+
toDownKeys: (alias) => fromAliasToDownKeys(alias),
|
|
763
959
|
toAliases: (event) => fromEventToAliases(event)
|
|
764
960
|
};
|
|
765
|
-
const createPredicateKeycomboMatch
|
|
766
|
-
const {
|
|
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
|
+
})();
|
|
767
972
|
return (event) => {
|
|
768
|
-
const
|
|
769
|
-
|
|
973
|
+
const statuses = createKeyStatuses(), predicateAliasDown = every(
|
|
974
|
+
(key) => statuses.toValue(key) === "down"
|
|
975
|
+
);
|
|
976
|
+
statuses.set(fromEventToKeyStatusKey(event), "down");
|
|
770
977
|
for (const modifier of modifiers) {
|
|
771
978
|
if (event[`${modifier.toLowerCase()}Key`])
|
|
772
|
-
set({ key: modifier }, "down");
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
979
|
+
statuses.set({ key: modifier }, "down");
|
|
980
|
+
}
|
|
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);
|
|
782
998
|
};
|
|
783
999
|
};
|
|
784
1000
|
|
|
785
|
-
const defaultOptions$
|
|
1001
|
+
const defaultOptions$h = {
|
|
786
1002
|
initial: [],
|
|
787
1003
|
createPredicateKey: (query) => (candidate) => query === candidate
|
|
788
1004
|
};
|
|
789
1005
|
function createAssociativeArray(options = {}) {
|
|
790
|
-
const { initial, createPredicateKey } = { ...defaultOptions$
|
|
1006
|
+
const { initial, createPredicateKey } = { ...defaultOptions$h, ...options }, entries = [...initial];
|
|
791
1007
|
const toValue = (key) => {
|
|
792
1008
|
const predicateKey = createPredicateKey(key);
|
|
793
1009
|
return find(
|
|
@@ -848,22 +1064,22 @@ function createAssociativeArray(options = {}) {
|
|
|
848
1064
|
};
|
|
849
1065
|
}
|
|
850
1066
|
|
|
851
|
-
const defaultOptions$
|
|
1067
|
+
const defaultOptions$g = {
|
|
852
1068
|
minDuration: 0,
|
|
853
1069
|
preventsDefaultUnlessDenied: true,
|
|
854
|
-
|
|
1070
|
+
toDownKeys: (alias) => fromAliasToDownKeys(alias),
|
|
855
1071
|
toAliases: (event) => fromEventToAliases(event)
|
|
856
1072
|
};
|
|
857
1073
|
function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
858
1074
|
const {
|
|
859
1075
|
minDuration,
|
|
860
1076
|
preventsDefaultUnlessDenied,
|
|
861
|
-
|
|
1077
|
+
toDownKeys,
|
|
862
1078
|
toAliases,
|
|
863
1079
|
onDown,
|
|
864
1080
|
onUp,
|
|
865
1081
|
onVisibilitychange
|
|
866
|
-
} = { ...defaultOptions$
|
|
1082
|
+
} = { ...defaultOptions$g, ...options }, {
|
|
867
1083
|
matchPredicatesByKeycombo,
|
|
868
1084
|
getDownCombos,
|
|
869
1085
|
predicateValid,
|
|
@@ -872,7 +1088,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
872
1088
|
} = createKeyState({
|
|
873
1089
|
keycomboOrKeycombos,
|
|
874
1090
|
unsupportedAliases: unsupportedAliases$2,
|
|
875
|
-
|
|
1091
|
+
toDownKeys,
|
|
876
1092
|
toAliases,
|
|
877
1093
|
getRequest: () => request
|
|
878
1094
|
});
|
|
@@ -971,22 +1187,22 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
971
1187
|
const unsupportedAliases$2 = ["meta", "command", "cmd"];
|
|
972
1188
|
const unsupportedKeys$2 = ["Meta"];
|
|
973
1189
|
|
|
974
|
-
const defaultOptions$
|
|
1190
|
+
const defaultOptions$f = {
|
|
975
1191
|
minDuration: 0,
|
|
976
1192
|
preventsDefaultUnlessDenied: true,
|
|
977
|
-
|
|
1193
|
+
toDownKeys: (alias) => fromAliasToDownKeys(alias),
|
|
978
1194
|
toAliases: (event) => fromEventToAliases(event)
|
|
979
1195
|
};
|
|
980
1196
|
function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
981
1197
|
const {
|
|
982
1198
|
minDuration,
|
|
983
1199
|
preventsDefaultUnlessDenied,
|
|
984
|
-
|
|
1200
|
+
toDownKeys,
|
|
985
1201
|
toAliases,
|
|
986
1202
|
onDown,
|
|
987
1203
|
onUp,
|
|
988
1204
|
onVisibilitychange
|
|
989
|
-
} = { ...defaultOptions$
|
|
1205
|
+
} = { ...defaultOptions$f, ...options }, {
|
|
990
1206
|
matchPredicatesByKeycombo,
|
|
991
1207
|
getDownCombos,
|
|
992
1208
|
predicateValid,
|
|
@@ -995,7 +1211,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
995
1211
|
} = createKeyState({
|
|
996
1212
|
keycomboOrKeycombos,
|
|
997
1213
|
unsupportedAliases: unsupportedAliases$1,
|
|
998
|
-
|
|
1214
|
+
toDownKeys,
|
|
999
1215
|
toAliases,
|
|
1000
1216
|
getRequest: () => request
|
|
1001
1217
|
});
|
|
@@ -1097,12 +1313,12 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1097
1313
|
const unsupportedAliases$1 = ["meta", "command", "cmd"];
|
|
1098
1314
|
const unsupportedKeys$1 = ["Meta"];
|
|
1099
1315
|
|
|
1100
|
-
const defaultOptions$
|
|
1316
|
+
const defaultOptions$e = {
|
|
1101
1317
|
minDuration: 0,
|
|
1102
1318
|
maxInterval: 5e3,
|
|
1103
1319
|
// VS Code default
|
|
1104
1320
|
preventsDefaultUnlessDenied: true,
|
|
1105
|
-
|
|
1321
|
+
toDownKeys: (alias) => fromAliasToDownKeys(alias),
|
|
1106
1322
|
toAliases: (event) => fromEventToAliases(event)
|
|
1107
1323
|
};
|
|
1108
1324
|
function createKeychord(keychord, options = {}) {
|
|
@@ -1110,15 +1326,15 @@ function createKeychord(keychord, options = {}) {
|
|
|
1110
1326
|
minDuration,
|
|
1111
1327
|
maxInterval,
|
|
1112
1328
|
preventsDefaultUnlessDenied,
|
|
1113
|
-
|
|
1329
|
+
toDownKeys,
|
|
1114
1330
|
toAliases,
|
|
1115
1331
|
onDown,
|
|
1116
1332
|
onUp,
|
|
1117
1333
|
onVisibilitychange
|
|
1118
|
-
} = { ...defaultOptions$
|
|
1334
|
+
} = { ...defaultOptions$e, ...options }, narrowedKeychord = keychord.split(" "), keyStates = createMap((keycombo) => createKeyState({
|
|
1119
1335
|
keycomboOrKeycombos: keycombo,
|
|
1120
1336
|
unsupportedAliases,
|
|
1121
|
-
|
|
1337
|
+
toDownKeys,
|
|
1122
1338
|
toAliases,
|
|
1123
1339
|
getRequest: () => request
|
|
1124
1340
|
}))(narrowedKeychord), localStatuses = createMap(
|
|
@@ -1263,7 +1479,7 @@ function createKonami(options = {}) {
|
|
|
1263
1479
|
return createKeychord("up up down down left right left right b a enter", options);
|
|
1264
1480
|
}
|
|
1265
1481
|
|
|
1266
|
-
const defaultOptions$
|
|
1482
|
+
const defaultOptions$d = {
|
|
1267
1483
|
minDuration: 0,
|
|
1268
1484
|
minDistance: 0,
|
|
1269
1485
|
getMousemoveTarget: (event) => event.target
|
|
@@ -1277,7 +1493,7 @@ function createMousepress(options = {}) {
|
|
|
1277
1493
|
onLeave,
|
|
1278
1494
|
onMove,
|
|
1279
1495
|
onUp
|
|
1280
|
-
} = { ...defaultOptions$
|
|
1496
|
+
} = { ...defaultOptions$d, ...options }, cleanup = (event) => {
|
|
1281
1497
|
window.cancelAnimationFrame(request);
|
|
1282
1498
|
getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
|
|
1283
1499
|
};
|
|
@@ -1337,7 +1553,7 @@ function createMousepress(options = {}) {
|
|
|
1337
1553
|
};
|
|
1338
1554
|
}
|
|
1339
1555
|
|
|
1340
|
-
const defaultOptions$
|
|
1556
|
+
const defaultOptions$c = {
|
|
1341
1557
|
minDuration: 0,
|
|
1342
1558
|
minDistance: 0,
|
|
1343
1559
|
minVelocity: 0,
|
|
@@ -1353,7 +1569,7 @@ function createMouserelease(options = {}) {
|
|
|
1353
1569
|
onLeave,
|
|
1354
1570
|
onMove,
|
|
1355
1571
|
onUp
|
|
1356
|
-
} = { ...defaultOptions$
|
|
1572
|
+
} = { ...defaultOptions$c, ...options }, cleanup = (event) => {
|
|
1357
1573
|
window.cancelAnimationFrame(request);
|
|
1358
1574
|
getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
|
|
1359
1575
|
};
|
|
@@ -1411,7 +1627,7 @@ function createMouserelease(options = {}) {
|
|
|
1411
1627
|
};
|
|
1412
1628
|
}
|
|
1413
1629
|
|
|
1414
|
-
const defaultOptions$
|
|
1630
|
+
const defaultOptions$b = {
|
|
1415
1631
|
minDuration: 0,
|
|
1416
1632
|
minDistance: 0
|
|
1417
1633
|
};
|
|
@@ -1423,7 +1639,7 @@ function createTouchpress(options = {}) {
|
|
|
1423
1639
|
onCancel,
|
|
1424
1640
|
onMove,
|
|
1425
1641
|
onEnd
|
|
1426
|
-
} = { ...defaultOptions$
|
|
1642
|
+
} = { ...defaultOptions$b, ...options }, cleanup = () => {
|
|
1427
1643
|
window.cancelAnimationFrame(request);
|
|
1428
1644
|
};
|
|
1429
1645
|
let request;
|
|
@@ -1484,7 +1700,7 @@ function createTouchpress(options = {}) {
|
|
|
1484
1700
|
};
|
|
1485
1701
|
}
|
|
1486
1702
|
|
|
1487
|
-
const defaultOptions$
|
|
1703
|
+
const defaultOptions$a = {
|
|
1488
1704
|
minDuration: 0,
|
|
1489
1705
|
minDistance: 0,
|
|
1490
1706
|
minVelocity: 0
|
|
@@ -1498,7 +1714,7 @@ function createTouchrelease(options = {}) {
|
|
|
1498
1714
|
onCancel,
|
|
1499
1715
|
onMove,
|
|
1500
1716
|
onEnd
|
|
1501
|
-
} = { ...defaultOptions$
|
|
1717
|
+
} = { ...defaultOptions$a, ...options }, cleanup = () => {
|
|
1502
1718
|
window.cancelAnimationFrame(request);
|
|
1503
1719
|
};
|
|
1504
1720
|
let request;
|
|
@@ -1565,12 +1781,12 @@ function createTouchrelease(options = {}) {
|
|
|
1565
1781
|
};
|
|
1566
1782
|
}
|
|
1567
1783
|
|
|
1568
|
-
const defaultOptions$
|
|
1784
|
+
const defaultOptions$9 = {
|
|
1569
1785
|
initial: []
|
|
1570
1786
|
};
|
|
1571
1787
|
function createKeyStatuses(options = {}) {
|
|
1572
1788
|
return createAssociativeArray({
|
|
1573
|
-
...defaultOptions$
|
|
1789
|
+
...defaultOptions$9,
|
|
1574
1790
|
...options,
|
|
1575
1791
|
createPredicateKey: (query) => (key) => {
|
|
1576
1792
|
for (const prop in query) {
|
|
@@ -1582,214 +1798,14 @@ function createKeyStatuses(options = {}) {
|
|
|
1582
1798
|
}
|
|
1583
1799
|
});
|
|
1584
1800
|
}
|
|
1585
|
-
function predicateDown(status) {
|
|
1586
|
-
return status === "down";
|
|
1587
|
-
}
|
|
1588
1801
|
function predicateSomeKeyDown(statuses) {
|
|
1589
1802
|
return includes("down")(statuses.toValues());
|
|
1590
1803
|
}
|
|
1591
1804
|
|
|
1592
|
-
function fromComboToAliases(combo) {
|
|
1593
|
-
const delimiter = "+";
|
|
1594
|
-
return pipe(
|
|
1595
|
-
unique(),
|
|
1596
|
-
map((name) => name === "" ? delimiter : name.toLowerCase()),
|
|
1597
|
-
toArray()
|
|
1598
|
-
)(combo.split(delimiter));
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
function fromAliasToKeyStatusKey(alias) {
|
|
1602
|
-
if (alias in keysByAlias) {
|
|
1603
|
-
return { key: keysByAlias[alias] };
|
|
1604
|
-
}
|
|
1605
|
-
return {
|
|
1606
|
-
code: (() => {
|
|
1607
|
-
if (alias in codesByAlias)
|
|
1608
|
-
return codesByAlias[alias];
|
|
1609
|
-
if (letterRE.test(alias))
|
|
1610
|
-
return `Key${alias.toUpperCase()}`;
|
|
1611
|
-
if (digitRE.test(alias))
|
|
1612
|
-
return `Digit${alias}`;
|
|
1613
|
-
if (functionRE.test(alias))
|
|
1614
|
-
return alias.toUpperCase();
|
|
1615
|
-
return "unsupported";
|
|
1616
|
-
})()
|
|
1617
|
-
};
|
|
1618
|
-
}
|
|
1619
|
-
const digitRE = /^[0-9]$/;
|
|
1620
|
-
const letterRE = /^[a-zA-Z]$/;
|
|
1621
|
-
const functionRE = /^[fF][0-9]{1,2}$/;
|
|
1622
|
-
const codesByAlias = {
|
|
1623
|
-
"`": "Backquote",
|
|
1624
|
-
"~": "Backquote",
|
|
1625
|
-
"-": "Minus",
|
|
1626
|
-
_: "Minus",
|
|
1627
|
-
"=": "Equal",
|
|
1628
|
-
"+": "Equal",
|
|
1629
|
-
"[": "BracketLeft",
|
|
1630
|
-
"{": "BracketLeft",
|
|
1631
|
-
"]": "BracketRight",
|
|
1632
|
-
"}": "BracketRight",
|
|
1633
|
-
"\\": "Backslash",
|
|
1634
|
-
"|": "Backslash",
|
|
1635
|
-
";": "Semicolon",
|
|
1636
|
-
":": "Semicolon",
|
|
1637
|
-
"'": "Quote",
|
|
1638
|
-
'"': "Quote",
|
|
1639
|
-
",": "Comma",
|
|
1640
|
-
"<": "Comma",
|
|
1641
|
-
".": "Period",
|
|
1642
|
-
">": "Period",
|
|
1643
|
-
"/": "Slash",
|
|
1644
|
-
"?": "Slash",
|
|
1645
|
-
"!": "Digit1",
|
|
1646
|
-
"@": "Digit2",
|
|
1647
|
-
"#": "Digit3",
|
|
1648
|
-
$: "Digit4",
|
|
1649
|
-
"%": "Digit5",
|
|
1650
|
-
"^": "Digit6",
|
|
1651
|
-
"&": "Digit7",
|
|
1652
|
-
"*": "Digit8",
|
|
1653
|
-
"(": "Digit9",
|
|
1654
|
-
")": "Digit0",
|
|
1655
|
-
up: "ArrowUp",
|
|
1656
|
-
down: "ArrowDown",
|
|
1657
|
-
left: "ArrowLeft",
|
|
1658
|
-
right: "ArrowRight",
|
|
1659
|
-
enter: "Enter",
|
|
1660
|
-
space: "Space",
|
|
1661
|
-
tab: "Tab",
|
|
1662
|
-
esc: "Escape",
|
|
1663
|
-
backspace: "Backspace",
|
|
1664
|
-
delete: "Delete",
|
|
1665
|
-
home: "Home",
|
|
1666
|
-
end: "End",
|
|
1667
|
-
pagedown: "PageDown",
|
|
1668
|
-
pageup: "PageUp",
|
|
1669
|
-
capslock: "CapsLock",
|
|
1670
|
-
camera: "Camera"
|
|
1671
|
-
};
|
|
1672
|
-
const keysByAlias = {
|
|
1673
|
-
alt: "Alt",
|
|
1674
|
-
opt: "Alt",
|
|
1675
|
-
option: "Alt",
|
|
1676
|
-
ctrl: "Control",
|
|
1677
|
-
control: "Control",
|
|
1678
|
-
meta: "Meta",
|
|
1679
|
-
cmd: "Meta",
|
|
1680
|
-
command: "Meta",
|
|
1681
|
-
shift: "Shift"
|
|
1682
|
-
};
|
|
1683
|
-
|
|
1684
|
-
const defaultOptions$a = {
|
|
1685
|
-
toKey: (alias) => fromAliasToKeyStatusKey(alias)
|
|
1686
|
-
};
|
|
1687
|
-
const createPredicateKeycomboDown = (keycombo, options = {}) => {
|
|
1688
|
-
const { toKey } = { ...defaultOptions$a, ...options }, keys = pipe(
|
|
1689
|
-
fromComboToAliases,
|
|
1690
|
-
map(toKey)
|
|
1691
|
-
)(keycombo);
|
|
1692
|
-
return (statuses) => {
|
|
1693
|
-
const { toValue } = statuses;
|
|
1694
|
-
return every(pipe(
|
|
1695
|
-
toValue,
|
|
1696
|
-
predicateDown
|
|
1697
|
-
))(keys);
|
|
1698
|
-
};
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
|
-
function fromEventToAliases(event) {
|
|
1702
|
-
if (event.shiftKey && event.code in aliasesByShiftCode) {
|
|
1703
|
-
return [aliasesByShiftCode[event.code]];
|
|
1704
|
-
}
|
|
1705
|
-
if (event.key in aliasListsByModifier) {
|
|
1706
|
-
return aliasListsByModifier[event.key];
|
|
1707
|
-
}
|
|
1708
|
-
return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
|
|
1709
|
-
}
|
|
1710
|
-
const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
|
|
1711
|
-
const aliasesByCode = {
|
|
1712
|
-
Backquote: "`",
|
|
1713
|
-
Minus: "-",
|
|
1714
|
-
Equal: "=",
|
|
1715
|
-
BracketLeft: "[",
|
|
1716
|
-
BracketRight: "]",
|
|
1717
|
-
Backslash: "\\",
|
|
1718
|
-
Semicolon: ";",
|
|
1719
|
-
Quote: "'",
|
|
1720
|
-
Comma: ",",
|
|
1721
|
-
Period: ".",
|
|
1722
|
-
Slash: "/",
|
|
1723
|
-
ArrowUp: "up",
|
|
1724
|
-
ArrowDown: "down",
|
|
1725
|
-
ArrowLeft: "left",
|
|
1726
|
-
ArrowRight: "right",
|
|
1727
|
-
Enter: "enter",
|
|
1728
|
-
Space: "space",
|
|
1729
|
-
Tab: "tab",
|
|
1730
|
-
Escape: "esc",
|
|
1731
|
-
Backspace: "backspace",
|
|
1732
|
-
Delete: "delete",
|
|
1733
|
-
Home: "home",
|
|
1734
|
-
End: "end",
|
|
1735
|
-
PageDown: "pagedown",
|
|
1736
|
-
PageUp: "pageup",
|
|
1737
|
-
CapsLock: "capslock",
|
|
1738
|
-
Camera: "camera"
|
|
1739
|
-
};
|
|
1740
|
-
const aliasesByShiftCode = {
|
|
1741
|
-
Backquote: "~",
|
|
1742
|
-
Minus: "_",
|
|
1743
|
-
Equal: "+",
|
|
1744
|
-
BracketLeft: "{",
|
|
1745
|
-
BracketRight: "}",
|
|
1746
|
-
Backslash: "|",
|
|
1747
|
-
Semicolon: ":",
|
|
1748
|
-
Quote: '"',
|
|
1749
|
-
Comma: "<",
|
|
1750
|
-
Period: ">",
|
|
1751
|
-
Slash: "?",
|
|
1752
|
-
Digit1: "!",
|
|
1753
|
-
Digit2: "@",
|
|
1754
|
-
Digit3: "#",
|
|
1755
|
-
Digit4: "$",
|
|
1756
|
-
Digit5: "%",
|
|
1757
|
-
Digit6: "^",
|
|
1758
|
-
Digit7: "&",
|
|
1759
|
-
Digit8: "*",
|
|
1760
|
-
Digit9: "(",
|
|
1761
|
-
Digit0: ")"
|
|
1762
|
-
};
|
|
1763
|
-
const aliasListsByModifier = {
|
|
1764
|
-
Alt: ["alt", "option", "opt"],
|
|
1765
|
-
Control: ["control", "ctrl"],
|
|
1766
|
-
Meta: ["meta", "command", "cmd"],
|
|
1767
|
-
Shift: ["shift"]
|
|
1768
|
-
};
|
|
1769
|
-
|
|
1770
|
-
const defaultOptions$9 = {
|
|
1771
|
-
toKey: (alias) => fromAliasToKeyStatusKey(alias),
|
|
1772
|
-
toAliases: (event) => fromEventToAliases(event)
|
|
1773
|
-
};
|
|
1774
|
-
const createPredicateKeycomboMatch = (keycombo, options = {}) => {
|
|
1775
|
-
const { toKey, toAliases } = { ...defaultOptions$9, ...options }, aliases = fromComboToAliases(keycombo), keys = map(toKey)(aliases);
|
|
1776
|
-
return (statuses) => {
|
|
1777
|
-
const { toValue } = statuses;
|
|
1778
|
-
return every(pipe(
|
|
1779
|
-
toValue,
|
|
1780
|
-
predicateDown
|
|
1781
|
-
))(keys) && every(
|
|
1782
|
-
([key, value]) => value === "up" || some(
|
|
1783
|
-
(alias) => includes(alias)(aliases)
|
|
1784
|
-
)(toAliases(key))
|
|
1785
|
-
)(statuses.toEntries());
|
|
1786
|
-
};
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
1805
|
function createKeyState({
|
|
1790
1806
|
keycomboOrKeycombos,
|
|
1791
1807
|
unsupportedAliases,
|
|
1792
|
-
|
|
1808
|
+
toDownKeys,
|
|
1793
1809
|
toAliases,
|
|
1794
1810
|
getRequest
|
|
1795
1811
|
}) {
|
|
@@ -1797,7 +1813,7 @@ function createKeyState({
|
|
|
1797
1813
|
(keycombo) => !some(
|
|
1798
1814
|
(alias) => includes(alias)(unsupportedAliases)
|
|
1799
1815
|
)(fromComboToAliases(keycombo))
|
|
1800
|
-
)(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = {
|
|
1816
|
+
)(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = { toDownKeys }, downPredicatesByKeycombo = (() => {
|
|
1801
1817
|
const predicates = [];
|
|
1802
1818
|
for (const keycombo of narrowedKeycombos) {
|
|
1803
1819
|
predicates.push([
|
|
@@ -1812,7 +1828,7 @@ function createKeyState({
|
|
|
1812
1828
|
})(), createPredicateKeycomboMatchOptions = { ...createPredicateKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
|
|
1813
1829
|
const predicates = {};
|
|
1814
1830
|
for (const keycombo of narrowedKeycombos) {
|
|
1815
|
-
predicates[keycombo] = createPredicateKeycomboMatch(
|
|
1831
|
+
predicates[keycombo] = createPredicateKeycomboMatch$1(
|
|
1816
1832
|
keycombo,
|
|
1817
1833
|
createPredicateKeycomboMatchOptions
|
|
1818
1834
|
);
|
|
@@ -4979,4 +4995,4 @@ class Storeable {
|
|
|
4979
4995
|
}
|
|
4980
4996
|
}
|
|
4981
4997
|
|
|
4982
|
-
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
|
|
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 };
|