@baleada/logic 0.23.4 → 0.24.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.
- package/lib/index.cjs +2268 -1915
- package/lib/index.d.ts +936 -587
- package/lib/index.js +2195 -1881
- package/package.json +4 -3
package/lib/index.js
CHANGED
|
@@ -1,97 +1,150 @@
|
|
|
1
1
|
import BezierEasing from 'bezier-easing';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getStroke } from 'perfect-freehand';
|
|
5
|
-
import polygonClipping from 'polygon-clipping';
|
|
6
|
-
import ky from 'ky';
|
|
2
|
+
import { pipe, flatMap, unique, map, toArray, concat, filter, reduce, slice, sort, find, findIndex, at, some, includes, toLength, join, every, reverse as reverse$1, average } from 'lazy-collections';
|
|
3
|
+
import { sortKind, Searcher } from 'fast-fuzzy';
|
|
7
4
|
import createDOMPurify from 'dompurify';
|
|
8
|
-
import
|
|
5
|
+
import slugify from '@sindresorhus/slugify';
|
|
6
|
+
import arrayShuffle from 'array-shuffle';
|
|
9
7
|
import { klona } from 'klona';
|
|
10
8
|
import { dequal } from 'dequal';
|
|
11
|
-
import
|
|
9
|
+
import { merge } from 'dset/merge';
|
|
10
|
+
import { getStroke } from 'perfect-freehand';
|
|
11
|
+
import polygonClipping from 'polygon-clipping';
|
|
12
|
+
import ky from 'ky';
|
|
12
13
|
import clsx from 'clsx';
|
|
13
14
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
function createClip(content) {
|
|
16
|
+
return (string) => {
|
|
17
|
+
return string.replace(content, "");
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createSlug(options) {
|
|
21
|
+
return (string) => {
|
|
22
|
+
return slugify(string, options);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createSanitize(options) {
|
|
26
|
+
const dompurify = createDOMPurify();
|
|
27
|
+
dompurify.setConfig(options);
|
|
28
|
+
return (string) => {
|
|
29
|
+
return dompurify.sanitize(string);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function createSplit(options) {
|
|
33
|
+
const { separator = "", limit } = options;
|
|
34
|
+
return (string) => {
|
|
35
|
+
return string.split(separator, limit);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function createNumber(options = {}) {
|
|
39
|
+
const { radix = 10 } = options;
|
|
40
|
+
return (string) => parseInt(string, radix);
|
|
41
|
+
}
|
|
42
|
+
function createResults(candidates, options = {}) {
|
|
43
|
+
const narrowedOptions = predicateFunction(options) ? options({ sortKind }) : options, searcher = new Searcher(candidates, narrowedOptions);
|
|
44
|
+
return (query) => searcher.search(query);
|
|
21
45
|
}
|
|
22
46
|
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
|
|
47
|
+
function fromShorthandAliasToLonghandAlias(shorthand) {
|
|
48
|
+
if (capitalLetterRE.test(shorthand))
|
|
49
|
+
return `shift+${shorthand.toLowerCase()}`;
|
|
50
|
+
if (shorthand in keycombosBySpecialCharacter)
|
|
51
|
+
return keycombosBySpecialCharacter[shorthand];
|
|
52
|
+
return shorthand;
|
|
53
|
+
}
|
|
54
|
+
const capitalLetterRE = /^[A-Z]$/;
|
|
55
|
+
const keycombosBySpecialCharacter = {
|
|
56
|
+
"~": "shift+`",
|
|
57
|
+
_: "shift+-",
|
|
58
|
+
"+": "shift+=",
|
|
59
|
+
"{": "shift+[",
|
|
60
|
+
"}": "shift+]",
|
|
61
|
+
"|": "shift+\\",
|
|
62
|
+
":": "shift+;",
|
|
63
|
+
'"': "shift+'",
|
|
64
|
+
"<": "shift+,",
|
|
65
|
+
">": "shift+.",
|
|
66
|
+
"?": "shift+/",
|
|
67
|
+
"!": "shift+1",
|
|
68
|
+
"@": "shift+2",
|
|
69
|
+
"#": "shift+3",
|
|
70
|
+
$: "shift+4",
|
|
71
|
+
"%": "shift+5",
|
|
72
|
+
"^": "shift+6",
|
|
73
|
+
"&": "shift+7",
|
|
74
|
+
"*": "shift+8",
|
|
75
|
+
"(": "shift+9",
|
|
76
|
+
")": "shift+0"
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function createAliases(options = {}) {
|
|
80
|
+
const { toLonghand = fromShorthandAliasToLonghandAlias } = options;
|
|
81
|
+
return (combo) => {
|
|
82
|
+
const separator = "+", splitByPlus = createSplit({ separator });
|
|
83
|
+
return pipe(
|
|
84
|
+
splitByPlus,
|
|
85
|
+
flatMap(
|
|
86
|
+
(alias) => pipe(
|
|
87
|
+
toLonghand,
|
|
88
|
+
splitByPlus
|
|
89
|
+
)(alias)
|
|
90
|
+
),
|
|
91
|
+
// If the separator is used as a character in the type,
|
|
92
|
+
// two empty strings will be produced by the split.
|
|
93
|
+
// unique() combines those two into one, and also removes
|
|
94
|
+
// duplicates in longhand transformations.
|
|
95
|
+
unique(),
|
|
96
|
+
map((name) => name === "" ? separator : name.toLowerCase()),
|
|
97
|
+
toArray()
|
|
98
|
+
)(combo);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function fromAliasToCode(alias) {
|
|
103
|
+
if (alias in partialCodesByAlias)
|
|
104
|
+
return partialCodesByAlias[alias];
|
|
27
105
|
if (alias in keyStatusKeysByAlias)
|
|
28
106
|
return keyStatusKeysByAlias[alias];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return alias.toUpperCase();
|
|
37
|
-
return "unsupported";
|
|
38
|
-
})()
|
|
39
|
-
}];
|
|
107
|
+
if (letterRE.test(alias))
|
|
108
|
+
return `Key${alias.toUpperCase()}`;
|
|
109
|
+
if (digitRE.test(alias))
|
|
110
|
+
return `Digit${alias}`;
|
|
111
|
+
if (functionRE.test(alias))
|
|
112
|
+
return alias.toUpperCase();
|
|
113
|
+
return "unsupported";
|
|
40
114
|
}
|
|
41
115
|
const digitRE = /^[0-9]$/;
|
|
42
116
|
const letterRE = /^[a-zA-Z]$/;
|
|
43
117
|
const functionRE = /^[fF][0-9]{1,2}$/;
|
|
44
118
|
const keyStatusKeysByAlias = {
|
|
45
|
-
"`":
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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" }]
|
|
119
|
+
"`": "Backquote",
|
|
120
|
+
"-": "Minus",
|
|
121
|
+
"=": "Equal",
|
|
122
|
+
"": "BracketLeft",
|
|
123
|
+
"]": "BracketRight",
|
|
124
|
+
"\\": "Backslash",
|
|
125
|
+
";": "Semicolon",
|
|
126
|
+
"'": "Quote",
|
|
127
|
+
",": "Comma",
|
|
128
|
+
".": "Period",
|
|
129
|
+
"/": "Slash",
|
|
130
|
+
up: "ArrowUp",
|
|
131
|
+
down: "ArrowDown",
|
|
132
|
+
left: "ArrowLeft",
|
|
133
|
+
right: "ArrowRight",
|
|
134
|
+
enter: "Enter",
|
|
135
|
+
space: "Space",
|
|
136
|
+
tab: "Tab",
|
|
137
|
+
esc: "Escape",
|
|
138
|
+
backspace: "Backspace",
|
|
139
|
+
delete: "Delete",
|
|
140
|
+
home: "Home",
|
|
141
|
+
end: "End",
|
|
142
|
+
pagedown: "PageDown",
|
|
143
|
+
pageup: "PageUp",
|
|
144
|
+
capslock: "CapsLock",
|
|
145
|
+
camera: "Camera"
|
|
93
146
|
};
|
|
94
|
-
const
|
|
147
|
+
const partialCodesByAlias = {
|
|
95
148
|
alt: "Alt",
|
|
96
149
|
opt: "Alt",
|
|
97
150
|
option: "Alt",
|
|
@@ -103,119 +156,6 @@ const keysByAlias = {
|
|
|
103
156
|
shift: "Shift"
|
|
104
157
|
};
|
|
105
158
|
|
|
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
|
-
|
|
210
|
-
function createClone() {
|
|
211
|
-
return (any) => {
|
|
212
|
-
return klona(any);
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function createEqual(compared) {
|
|
216
|
-
return (any) => dequal(any, compared);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
159
|
function createConcat(...arrays) {
|
|
220
160
|
return (array) => pipe(
|
|
221
161
|
concat(array, ...arrays),
|
|
@@ -295,6 +235,8 @@ function createReverse() {
|
|
|
295
235
|
};
|
|
296
236
|
}
|
|
297
237
|
function createSlice(from, to) {
|
|
238
|
+
if (from < 0 || to && to < 0)
|
|
239
|
+
return (array) => array.slice(from, to);
|
|
298
240
|
const toSliced = to ? slice(from, to - 1) : slice(from);
|
|
299
241
|
return (array) => {
|
|
300
242
|
return from === to ? [] : pipe(
|
|
@@ -303,6 +245,11 @@ function createSlice(from, to) {
|
|
|
303
245
|
)(array);
|
|
304
246
|
};
|
|
305
247
|
}
|
|
248
|
+
function createShuffle() {
|
|
249
|
+
return (array) => {
|
|
250
|
+
return arrayShuffle(array);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
306
253
|
function createSort(compare) {
|
|
307
254
|
return (array) => {
|
|
308
255
|
return pipe(
|
|
@@ -311,19 +258,19 @@ function createSort(compare) {
|
|
|
311
258
|
)(array);
|
|
312
259
|
};
|
|
313
260
|
}
|
|
314
|
-
function createSwap(
|
|
261
|
+
function createSwap(item1Index, item2Index) {
|
|
315
262
|
return (array) => {
|
|
316
|
-
const {
|
|
317
|
-
if (
|
|
263
|
+
const { reorderFrom, reorderTo } = (() => {
|
|
264
|
+
if (item1Index < item2Index) {
|
|
318
265
|
return {
|
|
319
|
-
reorderFrom: createReorder(
|
|
320
|
-
reorderTo: createReorder(
|
|
266
|
+
reorderFrom: createReorder(item1Index, item2Index),
|
|
267
|
+
reorderTo: createReorder(item2Index - 1, item1Index)
|
|
321
268
|
};
|
|
322
269
|
}
|
|
323
|
-
if (
|
|
270
|
+
if (item1Index > item2Index) {
|
|
324
271
|
return {
|
|
325
|
-
reorderFrom: createReorder(
|
|
326
|
-
reorderTo: createReorder(
|
|
272
|
+
reorderFrom: createReorder(item1Index, item2Index),
|
|
273
|
+
reorderTo: createReorder(item2Index + 1, item1Index)
|
|
327
274
|
};
|
|
328
275
|
}
|
|
329
276
|
return {
|
|
@@ -341,6 +288,55 @@ function createUnique() {
|
|
|
341
288
|
)(array);
|
|
342
289
|
}
|
|
343
290
|
|
|
291
|
+
function createClone() {
|
|
292
|
+
return (any) => {
|
|
293
|
+
return klona(any);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function createDeepEqual(compared) {
|
|
297
|
+
return (any) => dequal(any, compared);
|
|
298
|
+
}
|
|
299
|
+
function createEqual(compared) {
|
|
300
|
+
return (any) => any === compared;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function createValue$2(key, options = {}) {
|
|
304
|
+
const { predicateKey = createEqual(key) } = options;
|
|
305
|
+
return (associativeArray) => {
|
|
306
|
+
return find(
|
|
307
|
+
([candidate]) => predicateKey(candidate)
|
|
308
|
+
)(associativeArray)?.[1];
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function createHas$1(key, options = {}) {
|
|
312
|
+
const { predicateKey = createEqual(key) } = options;
|
|
313
|
+
return (associativeArray) => {
|
|
314
|
+
return findIndex(
|
|
315
|
+
([candidate]) => predicateKey(candidate)
|
|
316
|
+
)(associativeArray) !== -1;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function createKeys$1() {
|
|
320
|
+
return (associativeArray) => {
|
|
321
|
+
return createMap(([key]) => key)(associativeArray);
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function createValues$1() {
|
|
325
|
+
return (associativeArray) => {
|
|
326
|
+
return createMap(([, value]) => value)(associativeArray);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function createForEachAsync(effect) {
|
|
331
|
+
return async (array) => {
|
|
332
|
+
for (let i = 0; i < array.length; i++) {
|
|
333
|
+
const item = array[i];
|
|
334
|
+
await effect(item, i);
|
|
335
|
+
}
|
|
336
|
+
return array;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
344
340
|
function createFilterAsync(predicate) {
|
|
345
341
|
return async (array) => {
|
|
346
342
|
const transformedAsync = await createMapAsync(predicate)(array);
|
|
@@ -365,15 +361,6 @@ function createFindIndexAsync(predicate) {
|
|
|
365
361
|
}
|
|
366
362
|
};
|
|
367
363
|
}
|
|
368
|
-
function createForEachAsync(forEach) {
|
|
369
|
-
return async (array) => {
|
|
370
|
-
for (let i = 0; i < array.length; i++) {
|
|
371
|
-
const item = array[i];
|
|
372
|
-
await forEach(item, i);
|
|
373
|
-
}
|
|
374
|
-
return array;
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
364
|
function createMapAsync(transform) {
|
|
378
365
|
return async (array) => {
|
|
379
366
|
return await createReduceAsync(
|
|
@@ -398,709 +385,495 @@ function createReduceAsync(accumulate, initialValue) {
|
|
|
398
385
|
};
|
|
399
386
|
}
|
|
400
387
|
|
|
401
|
-
function
|
|
402
|
-
return (
|
|
403
|
-
return string.replace(required, "");
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
function createSlug(options) {
|
|
407
|
-
return (string) => {
|
|
408
|
-
return slugify(string, options);
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
function createClamp(min, max) {
|
|
413
|
-
return (number) => {
|
|
414
|
-
const maxed = Math.max(number, min);
|
|
415
|
-
return Math.min(maxed, max);
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
function createDetermine(potentialities) {
|
|
419
|
-
const predicates = createMap(({ outcome, probability }, index) => {
|
|
420
|
-
const lowerBound = index === 0 ? 0 : pipe(
|
|
421
|
-
slice(0, index - 1),
|
|
422
|
-
reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
|
|
423
|
-
)(potentialities), upperBound = lowerBound + probability;
|
|
424
|
-
return {
|
|
425
|
-
outcome,
|
|
426
|
-
predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
|
|
427
|
-
};
|
|
428
|
-
})(potentialities);
|
|
429
|
-
return (determinant) => find(({ predicate }) => predicate(determinant))(predicates).outcome;
|
|
388
|
+
function createList() {
|
|
389
|
+
return (...classValues) => clsx(...classValues);
|
|
430
390
|
}
|
|
431
391
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
return keys;
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
function createEvery(predicate) {
|
|
451
|
-
return (object) => {
|
|
452
|
-
for (const key in object) {
|
|
453
|
-
if (!predicate(key, object[key])) {
|
|
454
|
-
return false;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return true;
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
function createSome(predicate) {
|
|
461
|
-
return (object) => {
|
|
462
|
-
for (const key in object) {
|
|
463
|
-
if (predicate(key, object[key]))
|
|
464
|
-
return true;
|
|
465
|
-
}
|
|
466
|
-
return false;
|
|
392
|
+
const defaultCreateMixOptions = {
|
|
393
|
+
method: "oklch",
|
|
394
|
+
tag: "div",
|
|
395
|
+
getParent: () => document.body
|
|
396
|
+
};
|
|
397
|
+
function createMix(color2, options = {}) {
|
|
398
|
+
const { method, tag, getParent } = { ...defaultCreateMixOptions, ...options };
|
|
399
|
+
return (color1) => {
|
|
400
|
+
const element = document.createElement(tag), parent = getParent();
|
|
401
|
+
element.style.color = `color-mix(in ${method}, ${color1}, ${color2})`;
|
|
402
|
+
parent.appendChild(element);
|
|
403
|
+
const mixed = getComputedStyle(element).color;
|
|
404
|
+
parent.removeChild(element);
|
|
405
|
+
return mixed;
|
|
467
406
|
};
|
|
468
407
|
}
|
|
469
408
|
|
|
470
|
-
function
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
409
|
+
function createDepthPathConfig(directedAcyclic) {
|
|
410
|
+
const predicateTerminal = createTerminal(directedAcyclic), predicatePathable = (node) => !predicateTerminal(node), toTraversalCandidates = (path) => pipe(
|
|
411
|
+
at(-1),
|
|
412
|
+
createOutgoing(directedAcyclic)
|
|
413
|
+
)(path);
|
|
414
|
+
return { predicatePathable, toTraversalCandidates };
|
|
475
415
|
}
|
|
476
416
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
"textarea:not([disabled])",
|
|
484
|
-
"button:not([disabled])",
|
|
485
|
-
"a[href]",
|
|
486
|
-
"area[href]",
|
|
487
|
-
"summary",
|
|
488
|
-
"iframe",
|
|
489
|
-
"object",
|
|
490
|
-
"embed",
|
|
491
|
-
"audio[controls]",
|
|
492
|
-
"video[controls]",
|
|
493
|
-
"[contenteditable]",
|
|
494
|
-
"[tabindex]:not([disabled])"
|
|
495
|
-
])
|
|
496
|
-
};
|
|
497
|
-
function createFocusable(order, options = {}) {
|
|
498
|
-
const { elementIsCandidate, tabbableSelector } = { ...defaultOptions$k, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
|
|
499
|
-
return (element) => {
|
|
500
|
-
if (elementIsCandidate && predicateFocusable(element))
|
|
501
|
-
return element;
|
|
502
|
-
switch (order) {
|
|
503
|
-
case "first":
|
|
504
|
-
for (let i = 0; i < element.children.length; i++) {
|
|
505
|
-
const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
|
|
506
|
-
if (focusable)
|
|
507
|
-
return focusable;
|
|
508
|
-
}
|
|
509
|
-
break;
|
|
510
|
-
case "last":
|
|
511
|
-
for (let i = element.children.length - 1; i > -1; i--) {
|
|
512
|
-
const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
|
|
513
|
-
if (focusable)
|
|
514
|
-
return focusable;
|
|
515
|
-
}
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
};
|
|
417
|
+
function createBreadthPathConfig(directedAcyclic) {
|
|
418
|
+
const predicateOnlyChild = createOnlyChild(directedAcyclic), predicatePathable = (node) => !predicateOnlyChild(node), toTraversalCandidates = (path) => pipe(
|
|
419
|
+
at(-2),
|
|
420
|
+
createOutgoing(directedAcyclic)
|
|
421
|
+
)(path);
|
|
422
|
+
return { predicatePathable, toTraversalCandidates };
|
|
519
423
|
}
|
|
520
424
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return function toTree(directedAcyclic) {
|
|
582
|
-
const firstRoot = pipe(
|
|
583
|
-
createToRoots(),
|
|
584
|
-
at(0)
|
|
585
|
-
)(directedAcyclic), tree = [];
|
|
586
|
-
tree.push({
|
|
587
|
-
node: firstRoot,
|
|
588
|
-
children: []
|
|
589
|
-
});
|
|
590
|
-
for (const { path } of toSteps(directedAcyclic)) {
|
|
591
|
-
const node = path.at(-1), parent = path.at(-2);
|
|
592
|
-
if (parent) {
|
|
593
|
-
const parentTreeNode = createFind(parent)(tree);
|
|
594
|
-
if (parentTreeNode) {
|
|
595
|
-
parentTreeNode.children.push({
|
|
596
|
-
node,
|
|
597
|
-
children: []
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
return tree;
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
function createToCommonAncestors$2(directedAcyclic) {
|
|
606
|
-
const toNodeSteps = createToNodeSteps$2(directedAcyclic);
|
|
607
|
-
return function* (a, b) {
|
|
608
|
-
for (const { path: aPath } of toNodeSteps(a)) {
|
|
609
|
-
for (const { path: bPath } of toNodeSteps(b)) {
|
|
610
|
-
for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
|
|
611
|
-
for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
|
|
612
|
-
if (aPath[aPathIndex] === bPath[bPathIndex] && !includes(aPath[aPathIndex])([a, b])) {
|
|
613
|
-
yield {
|
|
614
|
-
node: aPath[aPathIndex],
|
|
615
|
-
distances: {
|
|
616
|
-
[a]: aPath.length - aPathIndex - 1,
|
|
617
|
-
[b]: bPath.length - bPathIndex - 1
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
425
|
+
class Recognizeable {
|
|
426
|
+
maxSequenceLength;
|
|
427
|
+
effects;
|
|
428
|
+
effectApi;
|
|
429
|
+
constructor(sequence, options = {}) {
|
|
430
|
+
const defaultOptions = {
|
|
431
|
+
maxSequenceLength: true,
|
|
432
|
+
effects: {}
|
|
433
|
+
};
|
|
434
|
+
this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
|
|
435
|
+
this.effects = options?.effects || defaultOptions.effects;
|
|
436
|
+
this.resetComputedMetadata();
|
|
437
|
+
this.setSequence(sequence);
|
|
438
|
+
this.effectApi = {
|
|
439
|
+
getStatus: () => this.status,
|
|
440
|
+
getMetadata: () => this.metadata,
|
|
441
|
+
setMetadata: (metadata) => this.computedMetadata = metadata,
|
|
442
|
+
recognized: () => this.recognized(),
|
|
443
|
+
denied: () => this.denied(),
|
|
444
|
+
ready: () => this.ready()
|
|
445
|
+
};
|
|
446
|
+
this.ready();
|
|
447
|
+
}
|
|
448
|
+
computedMetadata;
|
|
449
|
+
resetComputedMetadata() {
|
|
450
|
+
this.computedMetadata = {};
|
|
451
|
+
}
|
|
452
|
+
recognized() {
|
|
453
|
+
this.computedStatus = "recognized";
|
|
454
|
+
}
|
|
455
|
+
denied() {
|
|
456
|
+
this.computedStatus = "denied";
|
|
457
|
+
}
|
|
458
|
+
computedStatus;
|
|
459
|
+
ready() {
|
|
460
|
+
this.computedStatus = "ready";
|
|
461
|
+
}
|
|
462
|
+
get sequence() {
|
|
463
|
+
return this.computedSequence;
|
|
464
|
+
}
|
|
465
|
+
set sequence(sequence) {
|
|
466
|
+
this.setSequence(sequence);
|
|
467
|
+
}
|
|
468
|
+
get status() {
|
|
469
|
+
return this.computedStatus;
|
|
470
|
+
}
|
|
471
|
+
get metadata() {
|
|
472
|
+
return this.computedMetadata;
|
|
473
|
+
}
|
|
474
|
+
computedSequence;
|
|
475
|
+
setSequence(sequence) {
|
|
476
|
+
this.computedSequence = sequence;
|
|
477
|
+
return this;
|
|
478
|
+
}
|
|
479
|
+
recognize(sequenceItem, options = {}) {
|
|
480
|
+
this.recognizing();
|
|
481
|
+
const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
|
|
482
|
+
newSequence.push(sequenceItem2);
|
|
483
|
+
if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
|
|
484
|
+
newSequence.shift();
|
|
623
485
|
}
|
|
486
|
+
}, newSequence = [];
|
|
487
|
+
for (const sequenceItem2 of this.sequence) {
|
|
488
|
+
pushSequence(sequenceItem2);
|
|
624
489
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
some(({ path }) => includes(ancestor)(path))
|
|
633
|
-
)(descendant);
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function createToNodeSteps$2(directedAcyclic, options = {}) {
|
|
637
|
-
const toSteps = createToSteps$2(options.createToSteps);
|
|
638
|
-
return function* (node) {
|
|
639
|
-
yield* pipe(
|
|
640
|
-
toSteps,
|
|
641
|
-
filter(({ path }) => path.at(-1) === node)
|
|
642
|
-
)(directedAcyclic);
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
const defaultCreateToStepsOptions$1 = {
|
|
646
|
-
toUnsetMetadata: () => 0,
|
|
647
|
-
toMockMetadata: (node, totalConnectionsFollowed) => totalConnectionsFollowed,
|
|
648
|
-
kind: "directed acyclic"
|
|
649
|
-
};
|
|
650
|
-
function createToSteps$2(options = {}) {
|
|
651
|
-
const { toUnsetMetadata, toMockMetadata, root, kind } = { ...defaultCreateToStepsOptions$1, ...options };
|
|
652
|
-
return function* (directedAcyclic) {
|
|
653
|
-
const { nodes } = directedAcyclic, toOutdegree = createToOutdegree(directedAcyclic), toPath = createToPath$2(directedAcyclic), roots = pipe(
|
|
654
|
-
createToRoots({ kind }),
|
|
655
|
-
toArray()
|
|
656
|
-
)(directedAcyclic), state = {}, totalConnectionsFollowedByNode = {}, predicateExhausted = (node) => {
|
|
657
|
-
return totalConnectionsFollowedByNode[node] === toOutdegree(node);
|
|
490
|
+
pushSequence(sequenceItem);
|
|
491
|
+
this.effectApi.getSequence = () => newSequence;
|
|
492
|
+
this.effectApi.pushSequence = pushSequence;
|
|
493
|
+
this.effectApi.listenInjection = {
|
|
494
|
+
effect: options.listenInjection?.effect || (() => {
|
|
495
|
+
}),
|
|
496
|
+
optionsByType: options.listenInjection?.optionsByType || {}
|
|
658
497
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
498
|
+
this.effects[type]?.(sequenceItem, { ...this.effectApi });
|
|
499
|
+
switch (this.status) {
|
|
500
|
+
case "ready":
|
|
501
|
+
case "denied":
|
|
502
|
+
this.resetComputedMetadata();
|
|
503
|
+
this.setSequence([]);
|
|
504
|
+
break;
|
|
505
|
+
case "recognizing":
|
|
506
|
+
case "recognized":
|
|
507
|
+
this.setSequence(newSequence);
|
|
508
|
+
break;
|
|
664
509
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
const path3 = toPath(state);
|
|
675
|
-
location = path3.at(-2);
|
|
676
|
-
yield* toStep();
|
|
677
|
-
return;
|
|
510
|
+
return this;
|
|
511
|
+
}
|
|
512
|
+
recognizing() {
|
|
513
|
+
this.computedStatus = "recognizing";
|
|
514
|
+
}
|
|
515
|
+
toType(sequenceItem) {
|
|
516
|
+
if (predicateArray(sequenceItem)) {
|
|
517
|
+
if (sequenceItem[0] instanceof IntersectionObserverEntry) {
|
|
518
|
+
return "intersect";
|
|
678
519
|
}
|
|
679
|
-
if (
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
function createToPath$2(directedAcyclic) {
|
|
695
|
-
const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = pipe(
|
|
696
|
-
createToRoots(),
|
|
697
|
-
at(0)
|
|
698
|
-
)(directedAcyclic);
|
|
699
|
-
return (state) => {
|
|
700
|
-
const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
|
|
701
|
-
while (getLastOutdegree() > 0 && getLastStatus() === "set") {
|
|
702
|
-
const edge = pipe(
|
|
703
|
-
toOutgoing,
|
|
704
|
-
find(
|
|
705
|
-
({ predicateTraversable }) => predicateTraversable(state)
|
|
706
|
-
)
|
|
707
|
-
)(path.at(-1));
|
|
708
|
-
path.push(edge.to);
|
|
709
|
-
}
|
|
710
|
-
return path;
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
function createToRoots(options = {}) {
|
|
714
|
-
return function* (directedAcyclic) {
|
|
715
|
-
const { nodes } = directedAcyclic;
|
|
716
|
-
for (const node of nodes) {
|
|
717
|
-
if (createPredicateRoot(directedAcyclic)(node))
|
|
718
|
-
yield node;
|
|
719
|
-
if (options.kind === "arborescence")
|
|
720
|
-
break;
|
|
520
|
+
if (sequenceItem[0] instanceof MutationRecord) {
|
|
521
|
+
return "mutate";
|
|
522
|
+
}
|
|
523
|
+
if (sequenceItem[0] instanceof ResizeObserverEntry) {
|
|
524
|
+
return "resize";
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
if (sequenceItem instanceof MediaQueryListEvent) {
|
|
528
|
+
return sequenceItem.media;
|
|
529
|
+
}
|
|
530
|
+
if ("didTimeout" in sequenceItem) {
|
|
531
|
+
return "idle";
|
|
532
|
+
}
|
|
533
|
+
return sequenceItem.type;
|
|
721
534
|
}
|
|
722
|
-
}
|
|
535
|
+
}
|
|
723
536
|
}
|
|
724
537
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return layers;
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
function createToTree$1(options = {}) {
|
|
737
|
-
const toSteps = createToSteps$1(options.createToSteps);
|
|
738
|
-
return async function toTree(directedAcyclic) {
|
|
739
|
-
const firstRoot = pipe(
|
|
740
|
-
createToRoots(),
|
|
741
|
-
at(0)
|
|
742
|
-
)(directedAcyclic), tree = [];
|
|
743
|
-
tree.push({
|
|
744
|
-
node: firstRoot,
|
|
745
|
-
children: []
|
|
746
|
-
});
|
|
747
|
-
for await (const { path } of toSteps(directedAcyclic)) {
|
|
748
|
-
const node = path.at(-1), parent = path.at(-2);
|
|
749
|
-
if (parent) {
|
|
750
|
-
const parentTreeNode = createFind(parent)(tree);
|
|
751
|
-
if (parentTreeNode) {
|
|
752
|
-
parentTreeNode.children.push({
|
|
753
|
-
node,
|
|
754
|
-
children: []
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
}
|
|
538
|
+
class Listenable {
|
|
539
|
+
computedRecognizeable;
|
|
540
|
+
recognizeableEffectsKeys;
|
|
541
|
+
computedActive;
|
|
542
|
+
constructor(type, options) {
|
|
543
|
+
if (type === "recognizeable") {
|
|
544
|
+
this.computedRecognizeable = new Recognizeable([], options?.recognizeable);
|
|
545
|
+
this.recognizeableEffectsKeys = Object.keys(options?.recognizeable?.effects);
|
|
758
546
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
547
|
+
this.computedActive = /* @__PURE__ */ new Set();
|
|
548
|
+
this.setType(type);
|
|
549
|
+
this.ready();
|
|
550
|
+
}
|
|
551
|
+
computedStatus;
|
|
552
|
+
ready() {
|
|
553
|
+
this.computedStatus = "ready";
|
|
554
|
+
}
|
|
555
|
+
get type() {
|
|
556
|
+
return this.computedType;
|
|
557
|
+
}
|
|
558
|
+
set type(type) {
|
|
559
|
+
this.setType(type);
|
|
560
|
+
}
|
|
561
|
+
get status() {
|
|
562
|
+
return this.computedStatus;
|
|
563
|
+
}
|
|
564
|
+
get active() {
|
|
565
|
+
return this.computedActive;
|
|
566
|
+
}
|
|
567
|
+
get recognizeable() {
|
|
568
|
+
return this.computedRecognizeable;
|
|
569
|
+
}
|
|
570
|
+
computedType;
|
|
571
|
+
implementation;
|
|
572
|
+
setType(type) {
|
|
573
|
+
this.stop();
|
|
574
|
+
this.computedType = type;
|
|
575
|
+
this.implementation = toImplementation(type);
|
|
576
|
+
return this;
|
|
577
|
+
}
|
|
578
|
+
listen(effect, options = {}) {
|
|
579
|
+
switch (this.implementation) {
|
|
580
|
+
case "intersection":
|
|
581
|
+
this.intersectionListen(effect, options);
|
|
582
|
+
break;
|
|
583
|
+
case "mutation":
|
|
584
|
+
this.mutationListen(effect, options);
|
|
585
|
+
break;
|
|
586
|
+
case "resize":
|
|
587
|
+
this.resizeListen(effect, options);
|
|
588
|
+
break;
|
|
589
|
+
case "mediaquery":
|
|
590
|
+
this.mediaQueryListen(effect, options);
|
|
591
|
+
break;
|
|
592
|
+
case "idle":
|
|
593
|
+
this.idleListen(effect, options);
|
|
594
|
+
break;
|
|
595
|
+
case "message":
|
|
596
|
+
this.messageListen(effect, options);
|
|
597
|
+
break;
|
|
598
|
+
case "recognizeable":
|
|
599
|
+
this.recognizeableListen(effect, options);
|
|
600
|
+
break;
|
|
601
|
+
case "documentevent":
|
|
602
|
+
this.documentEventListen(effect, options);
|
|
603
|
+
break;
|
|
604
|
+
case "event":
|
|
605
|
+
this.eventListen(effect, options);
|
|
606
|
+
break;
|
|
781
607
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
608
|
+
this.listening();
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
intersectionListen(effect, options) {
|
|
612
|
+
const { target, observer } = { ...this.getDefaultListenOptions(), ...options }, id = new IntersectionObserver(effect, observer);
|
|
613
|
+
id.observe(target);
|
|
614
|
+
this.active.add({ target, id });
|
|
615
|
+
}
|
|
616
|
+
mutationListen(effect, options) {
|
|
617
|
+
const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new MutationObserver(effect);
|
|
618
|
+
id.observe(target, observe);
|
|
619
|
+
this.active.add({ target, id });
|
|
620
|
+
}
|
|
621
|
+
resizeListen(effect, options) {
|
|
622
|
+
const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new ResizeObserver(effect);
|
|
623
|
+
id.observe(target, observe);
|
|
624
|
+
this.active.add({ target, id });
|
|
625
|
+
}
|
|
626
|
+
mediaQueryListen(effect, options) {
|
|
627
|
+
const target = window.matchMedia(this.type), { instantEffect } = { ...this.getDefaultListenOptions(), ...options };
|
|
628
|
+
instantEffect(target);
|
|
629
|
+
const withApi = (event) => effect(event);
|
|
630
|
+
target.addEventListener("change", withApi);
|
|
631
|
+
this.active.add({ target, id: ["change", withApi] });
|
|
632
|
+
}
|
|
633
|
+
idleListen(effect, options) {
|
|
634
|
+
const { requestIdleCallback } = { ...this.getDefaultListenOptions(), ...options }, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
|
|
635
|
+
this.active.add({ target: window, id });
|
|
636
|
+
}
|
|
637
|
+
messageListen(effect, options) {
|
|
638
|
+
const { target = new BroadcastChannel("baleada") } = options;
|
|
639
|
+
target.addEventListener(this.type, (event) => effect(event));
|
|
640
|
+
this.active.add({ target, id: [this.type, effect] });
|
|
641
|
+
}
|
|
642
|
+
recognizeableListen(effect, options) {
|
|
643
|
+
const guardedEffect = (sequenceItem) => {
|
|
644
|
+
this.recognizeable.recognize(
|
|
645
|
+
sequenceItem,
|
|
646
|
+
{ listenInjection: { effect, optionsByType } }
|
|
647
|
+
);
|
|
648
|
+
if (this.recognizeable.status === "recognized")
|
|
649
|
+
effect(sequenceItem);
|
|
650
|
+
}, optionsByType = {};
|
|
651
|
+
for (const type of this.recognizeableEffectsKeys) {
|
|
652
|
+
optionsByType[type] = {
|
|
653
|
+
...this.getDefaultListenOptions(toImplementation(type)),
|
|
654
|
+
...options
|
|
815
655
|
};
|
|
816
656
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
if (predicateExhausted(location)) {
|
|
822
|
-
if (includes(location)(roots))
|
|
823
|
-
return;
|
|
824
|
-
state[location].status = "unset";
|
|
825
|
-
state[location].metadata = toUnsetMetadata(location);
|
|
826
|
-
const path3 = await toPath(state);
|
|
827
|
-
location = path3.at(-2);
|
|
828
|
-
yield* await toStep();
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
if (!(location in totalConnectionsFollowedByNode))
|
|
832
|
-
totalConnectionsFollowedByNode[location] = 0;
|
|
833
|
-
state[location].status = "set";
|
|
834
|
-
state[location].metadata = toMockMetadata(location, totalConnectionsFollowedByNode[location]);
|
|
835
|
-
const path2 = await toPath(state);
|
|
836
|
-
yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
|
|
837
|
-
totalConnectionsFollowedByNode[location]++;
|
|
838
|
-
const newLocation = path2.at(-1);
|
|
839
|
-
if (toOutdegree(newLocation) > 0)
|
|
840
|
-
location = newLocation;
|
|
841
|
-
yield* await toStep();
|
|
842
|
-
}
|
|
843
|
-
yield* await toStep();
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
function createToPath$1(directedAcyclic) {
|
|
847
|
-
const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = pipe(
|
|
848
|
-
createToRoots(),
|
|
849
|
-
at(0)
|
|
850
|
-
)(directedAcyclic);
|
|
851
|
-
return async (state) => {
|
|
852
|
-
const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
|
|
853
|
-
while (getLastOutdegree() > 0 && getLastStatus() === "set") {
|
|
854
|
-
const edge = await pipe(
|
|
855
|
-
toOutgoing,
|
|
856
|
-
toArray(),
|
|
857
|
-
createFindAsync(
|
|
858
|
-
async ({ predicateTraversable }) => await predicateTraversable(state)
|
|
859
|
-
)
|
|
860
|
-
)(path.at(-1));
|
|
861
|
-
path.push(edge.to);
|
|
657
|
+
for (const type of this.recognizeableEffectsKeys) {
|
|
658
|
+
const listenable = new Listenable(type);
|
|
659
|
+
listenable.listen(guardedEffect, options);
|
|
660
|
+
this.active.add({ id: listenable });
|
|
862
661
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
662
|
+
}
|
|
663
|
+
documentEventListen(effect, options) {
|
|
664
|
+
const narrowedOptions = {
|
|
665
|
+
...this.getDefaultListenOptions(),
|
|
666
|
+
target: document
|
|
667
|
+
};
|
|
668
|
+
this.eventListen(effect, narrowedOptions);
|
|
669
|
+
}
|
|
670
|
+
eventListen(effect, options) {
|
|
671
|
+
const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
|
|
672
|
+
this.addEventListeners(eventListeners, options);
|
|
673
|
+
}
|
|
674
|
+
addEventListeners(eventListeners, options) {
|
|
675
|
+
const { target } = { ...this.getDefaultListenOptions(), ...options };
|
|
676
|
+
for (const eventListener of eventListeners) {
|
|
677
|
+
target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
|
|
678
|
+
this.active.add({ target, id: eventListener });
|
|
877
679
|
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
})
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
680
|
+
}
|
|
681
|
+
listening() {
|
|
682
|
+
this.computedStatus = "listening";
|
|
683
|
+
}
|
|
684
|
+
stop(options = {}) {
|
|
685
|
+
const { target } = options;
|
|
686
|
+
switch (this.status) {
|
|
687
|
+
case "ready":
|
|
688
|
+
case void 0:
|
|
689
|
+
break;
|
|
690
|
+
default:
|
|
691
|
+
const stoppables = [...this.active].filter((active) => !target || ("target" in active ? active.target === target : false)), shouldUpdateStatus = stoppables.length === this.active.size;
|
|
692
|
+
for (const stoppable of stoppables) {
|
|
693
|
+
stop(stoppable);
|
|
694
|
+
this.active.delete(stoppable);
|
|
695
|
+
}
|
|
696
|
+
if (shouldUpdateStatus) {
|
|
697
|
+
this.stopped();
|
|
698
|
+
}
|
|
699
|
+
break;
|
|
896
700
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
701
|
+
return this;
|
|
702
|
+
}
|
|
703
|
+
stopped() {
|
|
704
|
+
this.computedStatus = "stopped";
|
|
705
|
+
}
|
|
706
|
+
getDefaultListenOptions(implementation) {
|
|
707
|
+
switch (implementation || this.implementation) {
|
|
708
|
+
case "intersection":
|
|
709
|
+
return {
|
|
710
|
+
target: document.querySelector("html"),
|
|
711
|
+
observer: {}
|
|
712
|
+
};
|
|
713
|
+
case "mutation":
|
|
714
|
+
return {
|
|
715
|
+
target: document.querySelector("html"),
|
|
716
|
+
observe: {}
|
|
717
|
+
};
|
|
718
|
+
case "resize":
|
|
719
|
+
return {
|
|
720
|
+
target: document.querySelector("html"),
|
|
721
|
+
observe: {}
|
|
722
|
+
};
|
|
723
|
+
case "mediaquery":
|
|
724
|
+
return {
|
|
725
|
+
instantEffect: () => {
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
case "idle":
|
|
729
|
+
return {
|
|
730
|
+
requestIdleCallback: {}
|
|
731
|
+
};
|
|
732
|
+
case "message":
|
|
733
|
+
return {
|
|
734
|
+
target: new BroadcastChannel("baleada")
|
|
735
|
+
};
|
|
736
|
+
case "recognizeable":
|
|
737
|
+
return {};
|
|
738
|
+
case "documentevent":
|
|
739
|
+
return {};
|
|
740
|
+
case "event":
|
|
741
|
+
return { target: document };
|
|
903
742
|
}
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
function createToSteps(options = {}) {
|
|
907
|
-
const withDefaults = {
|
|
908
|
-
...defaultCreateToStepsOptions,
|
|
909
|
-
...options
|
|
910
|
-
};
|
|
911
|
-
return createToSteps$2(
|
|
912
|
-
toCreateDirectedAcyclicToStepsOptions(withDefaults)
|
|
913
|
-
);
|
|
914
|
-
}
|
|
915
|
-
function createToPath(...params) {
|
|
916
|
-
return createToPath$2(...params);
|
|
743
|
+
}
|
|
917
744
|
}
|
|
918
|
-
function
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
745
|
+
function stop(stoppable) {
|
|
746
|
+
if (stoppable.id instanceof Listenable) {
|
|
747
|
+
stoppable.id.stop();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (some((type) => observerAssertionsByType[type](stoppable.id))(["intersect", "mutate", "resize"])) {
|
|
751
|
+
const { id: id2 } = stoppable;
|
|
752
|
+
id2.disconnect();
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
|
|
756
|
+
const { target: target2, id: id2 } = stoppable;
|
|
757
|
+
target2.removeEventListener(id2[0], id2[1]);
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (predicateNumber(stoppable.id)) {
|
|
761
|
+
const { target: target2, id: id2 } = stoppable;
|
|
762
|
+
target2.cancelIdleCallback(id2);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
|
|
766
|
+
const { target: target2, id: id2 } = stoppable;
|
|
767
|
+
target2.removeEventListener(id2[0], id2[1]);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const { target, id } = stoppable;
|
|
771
|
+
target.removeEventListener(id[0], id[1], id[2]);
|
|
927
772
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
return (...classValues) => clsx(...classValues);
|
|
773
|
+
function toImplementation(type) {
|
|
774
|
+
return find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
|
|
931
775
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
776
|
+
const predicatesByImplementation = /* @__PURE__ */ new Map([
|
|
777
|
+
[
|
|
778
|
+
"recognizeable",
|
|
779
|
+
(type) => type === "recognizeable"
|
|
780
|
+
],
|
|
781
|
+
[
|
|
782
|
+
"intersection",
|
|
783
|
+
(type) => type === "intersect"
|
|
784
|
+
],
|
|
785
|
+
[
|
|
786
|
+
"mutation",
|
|
787
|
+
(type) => type === "mutate"
|
|
788
|
+
],
|
|
789
|
+
[
|
|
790
|
+
"resize",
|
|
791
|
+
(type) => type === "resize"
|
|
792
|
+
],
|
|
793
|
+
[
|
|
794
|
+
"mediaquery",
|
|
795
|
+
(type) => implementationREs.mediaquery.test(type)
|
|
796
|
+
],
|
|
797
|
+
[
|
|
798
|
+
"idle",
|
|
799
|
+
(type) => type === "idle"
|
|
800
|
+
],
|
|
801
|
+
[
|
|
802
|
+
"message",
|
|
803
|
+
(type) => type === "message" || type === "messageerror"
|
|
804
|
+
],
|
|
805
|
+
[
|
|
806
|
+
"documentevent",
|
|
807
|
+
(type) => documentEvents.has(type)
|
|
808
|
+
],
|
|
809
|
+
[
|
|
810
|
+
"event",
|
|
811
|
+
() => true
|
|
812
|
+
]
|
|
813
|
+
]);
|
|
814
|
+
const documentEvents = /* @__PURE__ */ new Set([
|
|
815
|
+
"fullscreenchange",
|
|
816
|
+
"fullscreenerror",
|
|
817
|
+
"pointerlockchange",
|
|
818
|
+
"pointerlockerror",
|
|
819
|
+
"readystatechange",
|
|
820
|
+
"visibilitychange"
|
|
821
|
+
]);
|
|
822
|
+
const implementationREs = {
|
|
823
|
+
mediaquery: /^\(.+\)$/
|
|
936
824
|
};
|
|
937
|
-
function
|
|
938
|
-
const {
|
|
939
|
-
return
|
|
940
|
-
const root = tree[0], rootId = toId(root);
|
|
941
|
-
function* toPair(node, id) {
|
|
942
|
-
const children = toChildren(node) || [];
|
|
943
|
-
for (const child of children) {
|
|
944
|
-
const childId = toId(child);
|
|
945
|
-
yield {
|
|
946
|
-
node: childId,
|
|
947
|
-
edge: { from: id, to: childId }
|
|
948
|
-
};
|
|
949
|
-
yield* toPair(child, childId);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
yield { node: rootId };
|
|
953
|
-
yield* toPair(root, rootId);
|
|
954
|
-
};
|
|
825
|
+
function toAddEventListenerParams(type, effect, options) {
|
|
826
|
+
const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
|
|
827
|
+
return { exceptAndOnlyEffect, effectOptions };
|
|
955
828
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
};
|
|
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
|
-
})();
|
|
972
|
-
return (event) => {
|
|
973
|
-
const statuses = createKeyStatuses(), predicateAliasDown = every(
|
|
974
|
-
(key) => statuses.toValue(key) === "down"
|
|
975
|
-
);
|
|
976
|
-
statuses.set(fromEventToKeyStatusKey(event), "down");
|
|
977
|
-
for (const modifier of modifiers) {
|
|
978
|
-
if (event[`${modifier.toLowerCase()}Key`])
|
|
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);
|
|
998
|
-
};
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
|
-
const defaultOptions$h = {
|
|
1002
|
-
initial: [],
|
|
1003
|
-
createPredicateKey: (query) => (candidate) => query === candidate
|
|
829
|
+
const observerAssertionsByType = {
|
|
830
|
+
intersect: (observer) => observer instanceof IntersectionObserver,
|
|
831
|
+
mutate: (observer) => observer instanceof MutationObserver,
|
|
832
|
+
resize: (observer) => observer instanceof ResizeObserver
|
|
1004
833
|
};
|
|
1005
|
-
function createAssociativeArray(options = {}) {
|
|
1006
|
-
const { initial, createPredicateKey } = { ...defaultOptions$h, ...options }, entries = [...initial];
|
|
1007
|
-
const toValue = (key) => {
|
|
1008
|
-
const predicateKey = createPredicateKey(key);
|
|
1009
|
-
return find(
|
|
1010
|
-
([candidate]) => predicateKey(candidate)
|
|
1011
|
-
)(entries)?.[1];
|
|
1012
|
-
};
|
|
1013
|
-
const set = (key, value) => {
|
|
1014
|
-
const predicateKey = createPredicateKey(key), index = findIndex(
|
|
1015
|
-
([candidate]) => predicateKey(candidate)
|
|
1016
|
-
)(entries);
|
|
1017
|
-
if (index === -1) {
|
|
1018
|
-
entries.push([key, value]);
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
entries[index][1] = value;
|
|
1022
|
-
};
|
|
1023
|
-
const predicateHas = (key) => {
|
|
1024
|
-
const predicateKey = createPredicateKey(key);
|
|
1025
|
-
return findIndex(
|
|
1026
|
-
([candidate]) => predicateKey(candidate)
|
|
1027
|
-
)(entries) !== -1;
|
|
1028
|
-
};
|
|
1029
|
-
const clear = () => {
|
|
1030
|
-
entries.length = 0;
|
|
1031
|
-
};
|
|
1032
|
-
const del = (key) => {
|
|
1033
|
-
const predicateKey = createPredicateKey(key), index = findIndex(
|
|
1034
|
-
([candidate]) => predicateKey(candidate)
|
|
1035
|
-
)(entries);
|
|
1036
|
-
if (index === -1) {
|
|
1037
|
-
return false;
|
|
1038
|
-
}
|
|
1039
|
-
entries.splice(index, 1);
|
|
1040
|
-
return true;
|
|
1041
|
-
};
|
|
1042
|
-
const toKeys = () => {
|
|
1043
|
-
return createMap(([key]) => key)(entries);
|
|
1044
|
-
};
|
|
1045
|
-
const toValues = () => {
|
|
1046
|
-
return createMap(([, value]) => value)(entries);
|
|
1047
|
-
};
|
|
1048
|
-
const toEntries = () => {
|
|
1049
|
-
return entries;
|
|
1050
|
-
};
|
|
1051
|
-
return {
|
|
1052
|
-
toValue,
|
|
1053
|
-
set,
|
|
1054
|
-
predicateHas,
|
|
1055
|
-
clear,
|
|
1056
|
-
delete: del,
|
|
1057
|
-
toKeys,
|
|
1058
|
-
toValues,
|
|
1059
|
-
toEntries
|
|
1060
|
-
// get: toValue,
|
|
1061
|
-
// has: predicateHas,
|
|
1062
|
-
// keys: toKeys,
|
|
1063
|
-
// values: toValues,
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
834
|
|
|
1067
|
-
const defaultOptions$
|
|
835
|
+
const defaultOptions$k = {
|
|
1068
836
|
minDuration: 0,
|
|
1069
837
|
preventsDefaultUnlessDenied: true,
|
|
1070
|
-
|
|
1071
|
-
toAliases: (
|
|
838
|
+
toCode: (alias) => fromAliasToCode(alias),
|
|
839
|
+
toAliases: (code) => fromCodeToAliases(code)
|
|
1072
840
|
};
|
|
1073
841
|
function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
1074
842
|
const {
|
|
1075
843
|
minDuration,
|
|
1076
844
|
preventsDefaultUnlessDenied,
|
|
1077
|
-
|
|
845
|
+
toLonghand,
|
|
846
|
+
toCode,
|
|
1078
847
|
toAliases,
|
|
1079
848
|
onDown,
|
|
1080
849
|
onUp,
|
|
1081
850
|
onVisibilitychange
|
|
1082
|
-
} = { ...defaultOptions$
|
|
851
|
+
} = { ...defaultOptions$k, ...options }, {
|
|
1083
852
|
matchPredicatesByKeycombo,
|
|
1084
853
|
getDownCombos,
|
|
1085
854
|
predicateValid,
|
|
1086
855
|
cleanup,
|
|
1087
|
-
statuses
|
|
856
|
+
statuses,
|
|
857
|
+
toStatus,
|
|
858
|
+
setStatus,
|
|
859
|
+
clearStatuses,
|
|
860
|
+
deleteStatus
|
|
1088
861
|
} = createKeyState({
|
|
1089
862
|
keycomboOrKeycombos,
|
|
1090
|
-
|
|
1091
|
-
|
|
863
|
+
toLonghand,
|
|
864
|
+
toCode,
|
|
1092
865
|
toAliases,
|
|
1093
866
|
getRequest: () => request
|
|
1094
|
-
});
|
|
867
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand });
|
|
1095
868
|
let request;
|
|
1096
869
|
let localStatus;
|
|
1097
870
|
const keydown = (event, api) => {
|
|
1098
|
-
const { denied, getStatus } = api, key =
|
|
1099
|
-
if (
|
|
871
|
+
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
872
|
+
if (toStatus(key) === "down") {
|
|
1100
873
|
onDown?.(toHookApi(api));
|
|
1101
874
|
return;
|
|
1102
875
|
}
|
|
1103
|
-
|
|
876
|
+
setStatus(key, "down");
|
|
1104
877
|
if (localStatus === "denied") {
|
|
1105
878
|
denied();
|
|
1106
879
|
onDown?.(toHookApi(api));
|
|
@@ -1113,15 +886,15 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
1113
886
|
) {
|
|
1114
887
|
denied();
|
|
1115
888
|
localStatus = getStatus();
|
|
1116
|
-
if (includes(event.key)(unsupportedKeys
|
|
1117
|
-
|
|
889
|
+
if (includes(event.key)(unsupportedKeys))
|
|
890
|
+
clearStatuses();
|
|
1118
891
|
onDown?.(toHookApi(api));
|
|
1119
892
|
return;
|
|
1120
893
|
}
|
|
1121
894
|
if (preventsDefaultUnlessDenied)
|
|
1122
895
|
event.preventDefault();
|
|
1123
896
|
const { getMetadata } = api, metadata = getMetadata();
|
|
1124
|
-
metadata.
|
|
897
|
+
metadata.keycombo = downCombos[0];
|
|
1125
898
|
localStatus = "recognizing";
|
|
1126
899
|
cleanup();
|
|
1127
900
|
storeKeyboardTimeMetadata({
|
|
@@ -1130,6 +903,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
1130
903
|
getTimeMetadata: getMetadata,
|
|
1131
904
|
getShouldStore: () => downCombos.length && getDownCombos()[0] === downCombos[0],
|
|
1132
905
|
setRequest: (newRequest) => request = newRequest,
|
|
906
|
+
// @ts-expect-error
|
|
1133
907
|
recognize
|
|
1134
908
|
});
|
|
1135
909
|
onDown?.(toHookApi(api));
|
|
@@ -1143,23 +917,23 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
1143
917
|
}
|
|
1144
918
|
};
|
|
1145
919
|
const keyup = (event, api) => {
|
|
1146
|
-
const { denied } = api, key =
|
|
920
|
+
const { denied } = api, key = fromEventToKeyStatusCode(event);
|
|
1147
921
|
if (localStatus === "denied") {
|
|
1148
922
|
denied();
|
|
1149
|
-
if (includes(event.key)(unsupportedKeys
|
|
1150
|
-
|
|
923
|
+
if (includes(event.key)(unsupportedKeys))
|
|
924
|
+
clearStatuses();
|
|
1151
925
|
else
|
|
1152
|
-
|
|
926
|
+
deleteStatus(key);
|
|
1153
927
|
if (!predicateSomeKeyDown(statuses))
|
|
1154
928
|
localStatus = "recognizing";
|
|
1155
929
|
onUp?.(toHookApi(api));
|
|
1156
930
|
return;
|
|
1157
931
|
}
|
|
1158
|
-
|
|
932
|
+
deleteStatus(key);
|
|
1159
933
|
const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
|
|
1160
934
|
if (downCombos.length && matches) {
|
|
1161
935
|
const { getMetadata } = api, metadata = getMetadata();
|
|
1162
|
-
metadata.
|
|
936
|
+
metadata.keycombo = downCombos[0];
|
|
1163
937
|
if (preventsDefaultUnlessDenied)
|
|
1164
938
|
event.preventDefault();
|
|
1165
939
|
localStatus = "recognizing";
|
|
@@ -1172,7 +946,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
1172
946
|
};
|
|
1173
947
|
const visibilitychange = (event, api) => {
|
|
1174
948
|
if (document.visibilityState === "hidden") {
|
|
1175
|
-
|
|
949
|
+
clearStatuses();
|
|
1176
950
|
localStatus = "recognizing";
|
|
1177
951
|
cleanup();
|
|
1178
952
|
}
|
|
@@ -1184,45 +958,63 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
1184
958
|
visibilitychange
|
|
1185
959
|
};
|
|
1186
960
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
961
|
+
class Keypress extends Listenable {
|
|
962
|
+
constructor(keycomboOrKeycombos, options) {
|
|
963
|
+
super(
|
|
964
|
+
"recognizeable",
|
|
965
|
+
{
|
|
966
|
+
recognizeable: {
|
|
967
|
+
effects: createKeypress(keycomboOrKeycombos, options)
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
get metadata() {
|
|
973
|
+
return this.recognizeable.metadata;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
1189
976
|
|
|
1190
|
-
const defaultOptions$
|
|
977
|
+
const defaultOptions$j = {
|
|
1191
978
|
minDuration: 0,
|
|
1192
979
|
preventsDefaultUnlessDenied: true,
|
|
1193
|
-
|
|
1194
|
-
toAliases: (
|
|
980
|
+
toCode: (alias) => fromAliasToCode(alias),
|
|
981
|
+
toAliases: (code) => fromCodeToAliases(code)
|
|
1195
982
|
};
|
|
1196
983
|
function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
1197
984
|
const {
|
|
1198
985
|
minDuration,
|
|
1199
986
|
preventsDefaultUnlessDenied,
|
|
1200
|
-
|
|
987
|
+
toLonghand,
|
|
988
|
+
toCode,
|
|
1201
989
|
toAliases,
|
|
1202
990
|
onDown,
|
|
1203
991
|
onUp,
|
|
1204
992
|
onVisibilitychange
|
|
1205
|
-
} = { ...defaultOptions$
|
|
993
|
+
} = { ...defaultOptions$j, ...options }, {
|
|
1206
994
|
matchPredicatesByKeycombo,
|
|
1207
995
|
getDownCombos,
|
|
1208
996
|
predicateValid,
|
|
1209
997
|
cleanup,
|
|
1210
|
-
statuses
|
|
998
|
+
statuses,
|
|
999
|
+
toStatus,
|
|
1000
|
+
setStatus,
|
|
1001
|
+
clearStatuses,
|
|
1002
|
+
deleteStatus
|
|
1211
1003
|
} = createKeyState({
|
|
1212
1004
|
keycomboOrKeycombos,
|
|
1213
|
-
|
|
1214
|
-
|
|
1005
|
+
toLonghand,
|
|
1006
|
+
toCode,
|
|
1215
1007
|
toAliases,
|
|
1216
1008
|
getRequest: () => request
|
|
1217
|
-
});
|
|
1009
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand });
|
|
1218
1010
|
let request, localStatus;
|
|
1219
1011
|
const keydown = (event, api) => {
|
|
1220
|
-
const { denied, getStatus } = api, key =
|
|
1221
|
-
if (
|
|
1012
|
+
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
1013
|
+
if (toStatus(key) === "down") {
|
|
1222
1014
|
onDown?.(toHookApi(api));
|
|
1223
1015
|
return;
|
|
1224
1016
|
}
|
|
1225
|
-
|
|
1017
|
+
setStatus(key, "down");
|
|
1226
1018
|
if (localStatus === "denied") {
|
|
1227
1019
|
denied();
|
|
1228
1020
|
onDown?.(toHookApi(api));
|
|
@@ -1235,8 +1027,8 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1235
1027
|
) {
|
|
1236
1028
|
denied();
|
|
1237
1029
|
localStatus = getStatus();
|
|
1238
|
-
if (includes(event.key)(unsupportedKeys
|
|
1239
|
-
|
|
1030
|
+
if (includes(event.key)(unsupportedKeys))
|
|
1031
|
+
clearStatuses();
|
|
1240
1032
|
onDown?.(toHookApi(api));
|
|
1241
1033
|
return;
|
|
1242
1034
|
}
|
|
@@ -1259,21 +1051,21 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1259
1051
|
getStatus,
|
|
1260
1052
|
getMetadata,
|
|
1261
1053
|
denied
|
|
1262
|
-
} = api, metadata = getMetadata(), key =
|
|
1054
|
+
} = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
|
|
1263
1055
|
if (["denied", "recognized"].includes(localStatus)) {
|
|
1264
1056
|
if (localStatus === "denied")
|
|
1265
1057
|
denied();
|
|
1266
|
-
if (includes(event.key)(unsupportedKeys
|
|
1267
|
-
|
|
1058
|
+
if (includes(event.key)(unsupportedKeys))
|
|
1059
|
+
clearStatuses();
|
|
1268
1060
|
else
|
|
1269
|
-
|
|
1061
|
+
deleteStatus(key);
|
|
1270
1062
|
if (!predicateSomeKeyDown(statuses))
|
|
1271
1063
|
localStatus = "recognizing";
|
|
1272
1064
|
onUp?.(toHookApi(api));
|
|
1273
1065
|
return;
|
|
1274
1066
|
}
|
|
1275
1067
|
const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
|
|
1276
|
-
|
|
1068
|
+
deleteStatus(key);
|
|
1277
1069
|
if (!downCombos.length || !matches) {
|
|
1278
1070
|
onUp?.(toHookApi(api));
|
|
1279
1071
|
return;
|
|
@@ -1282,7 +1074,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1282
1074
|
const status = getStatus();
|
|
1283
1075
|
if (status === "recognized") {
|
|
1284
1076
|
localStatus = status;
|
|
1285
|
-
metadata.
|
|
1077
|
+
metadata.keycombo = downCombos[0];
|
|
1286
1078
|
}
|
|
1287
1079
|
if (preventsDefaultUnlessDenied)
|
|
1288
1080
|
event.preventDefault();
|
|
@@ -1298,7 +1090,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1298
1090
|
};
|
|
1299
1091
|
const visibilitychange = (event, api) => {
|
|
1300
1092
|
if (document.visibilityState === "hidden") {
|
|
1301
|
-
|
|
1093
|
+
clearStatuses();
|
|
1302
1094
|
localStatus = "recognizing";
|
|
1303
1095
|
cleanup();
|
|
1304
1096
|
}
|
|
@@ -1310,50 +1102,64 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1310
1102
|
visibilitychange
|
|
1311
1103
|
};
|
|
1312
1104
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1105
|
+
class Keyrelease extends Listenable {
|
|
1106
|
+
constructor(keycomboOrKeycombos, options) {
|
|
1107
|
+
super(
|
|
1108
|
+
"recognizeable",
|
|
1109
|
+
{
|
|
1110
|
+
recognizeable: {
|
|
1111
|
+
effects: createKeyrelease(keycomboOrKeycombos, options)
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
get metadata() {
|
|
1117
|
+
return this.recognizeable.metadata;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1315
1120
|
|
|
1316
|
-
const defaultOptions$
|
|
1121
|
+
const defaultOptions$i = {
|
|
1317
1122
|
minDuration: 0,
|
|
1318
1123
|
maxInterval: 5e3,
|
|
1319
1124
|
// VS Code default
|
|
1320
1125
|
preventsDefaultUnlessDenied: true,
|
|
1321
|
-
|
|
1322
|
-
toAliases: (
|
|
1126
|
+
toCode: (alias) => fromAliasToCode(alias),
|
|
1127
|
+
toAliases: (code) => fromCodeToAliases(code)
|
|
1323
1128
|
};
|
|
1324
|
-
function createKeychord(
|
|
1129
|
+
function createKeychord(keycombos, options = {}) {
|
|
1325
1130
|
const {
|
|
1326
1131
|
minDuration,
|
|
1327
1132
|
maxInterval,
|
|
1328
1133
|
preventsDefaultUnlessDenied,
|
|
1329
|
-
|
|
1134
|
+
toLonghand,
|
|
1135
|
+
toCode,
|
|
1330
1136
|
toAliases,
|
|
1331
1137
|
onDown,
|
|
1332
1138
|
onUp,
|
|
1333
1139
|
onVisibilitychange
|
|
1334
|
-
} = { ...defaultOptions$
|
|
1140
|
+
} = { ...defaultOptions$i, ...options }, narrowedKeycombos = keycombos.split(" "), keyStates = createMap((keycombo) => createKeyState({
|
|
1335
1141
|
keycomboOrKeycombos: keycombo,
|
|
1336
|
-
|
|
1337
|
-
|
|
1142
|
+
toLonghand,
|
|
1143
|
+
toCode,
|
|
1338
1144
|
toAliases,
|
|
1339
1145
|
getRequest: () => request
|
|
1340
|
-
}))(
|
|
1146
|
+
}))(narrowedKeycombos), localStatuses = createMap(
|
|
1341
1147
|
() => "recognizing"
|
|
1342
|
-
)(keyStates);
|
|
1148
|
+
)(keyStates), fromComboToAliasesLength = createAliasesLength({ toLonghand });
|
|
1343
1149
|
let request, playedIndex = 0;
|
|
1344
1150
|
const keydown = (event, api) => {
|
|
1345
|
-
const { denied, getStatus } = api, key =
|
|
1346
|
-
if (keyStates[playedIndex].
|
|
1151
|
+
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
1152
|
+
if (keyStates[playedIndex].toStatus(key) === "down") {
|
|
1347
1153
|
onDown?.(toHookApi(api));
|
|
1348
1154
|
return;
|
|
1349
1155
|
}
|
|
1350
1156
|
if (localStatuses[playedIndex] === "recognized") {
|
|
1351
1157
|
playedIndex++;
|
|
1352
|
-
for (const [key2, status] of keyStates[playedIndex - 1].statuses
|
|
1353
|
-
keyStates[playedIndex].
|
|
1158
|
+
for (const [key2, status] of keyStates[playedIndex - 1].statuses) {
|
|
1159
|
+
keyStates[playedIndex].setStatus(key2, status);
|
|
1354
1160
|
}
|
|
1355
1161
|
}
|
|
1356
|
-
keyStates[playedIndex].
|
|
1162
|
+
keyStates[playedIndex].setStatus(key, "down");
|
|
1357
1163
|
if (localStatuses[playedIndex] === "denied") {
|
|
1358
1164
|
denied();
|
|
1359
1165
|
onDown?.(toHookApi(api));
|
|
@@ -1369,8 +1175,8 @@ function createKeychord(keychord, options = {}) {
|
|
|
1369
1175
|
denied();
|
|
1370
1176
|
localStatuses[playedIndex] = getStatus();
|
|
1371
1177
|
if (includes(event.key)(unsupportedKeys)) {
|
|
1372
|
-
for (const {
|
|
1373
|
-
|
|
1178
|
+
for (const { clearStatuses } of keyStates)
|
|
1179
|
+
clearStatuses();
|
|
1374
1180
|
}
|
|
1375
1181
|
onDown?.(toHookApi(api));
|
|
1376
1182
|
return;
|
|
@@ -1396,30 +1202,30 @@ function createKeychord(keychord, options = {}) {
|
|
|
1396
1202
|
getStatus,
|
|
1397
1203
|
getMetadata,
|
|
1398
1204
|
denied
|
|
1399
|
-
} = api, metadata = getMetadata(), key =
|
|
1205
|
+
} = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
|
|
1400
1206
|
if (["denied", "recognized"].includes(localStatuses[playedIndex])) {
|
|
1401
1207
|
if (localStatuses[playedIndex] === "denied")
|
|
1402
1208
|
denied();
|
|
1403
|
-
for (const {
|
|
1209
|
+
for (const { clearStatuses, deleteStatus } of keyStates) {
|
|
1404
1210
|
if (includes(event.key)(unsupportedKeys))
|
|
1405
|
-
|
|
1211
|
+
clearStatuses();
|
|
1406
1212
|
else
|
|
1407
|
-
|
|
1213
|
+
deleteStatus(key);
|
|
1408
1214
|
}
|
|
1409
1215
|
if (!predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
|
|
1410
|
-
if (localStatuses[playedIndex] === "denied" || playedIndex ===
|
|
1216
|
+
if (localStatuses[playedIndex] === "denied" || playedIndex === narrowedKeycombos.length - 1 && localStatuses[playedIndex] === "recognized") {
|
|
1411
1217
|
playedIndex = 0;
|
|
1412
1218
|
for (let i = 0; i < localStatuses.length; i++)
|
|
1413
1219
|
localStatuses[i] = "recognizing";
|
|
1414
|
-
for (const {
|
|
1415
|
-
|
|
1220
|
+
for (const { clearStatuses } of keyStates)
|
|
1221
|
+
clearStatuses();
|
|
1416
1222
|
}
|
|
1417
1223
|
}
|
|
1418
1224
|
onUp?.(toHookApi(api));
|
|
1419
1225
|
return;
|
|
1420
1226
|
}
|
|
1421
1227
|
const downCombos = keyStates[playedIndex].getDownCombos(), matches = keyStates[playedIndex].matchPredicatesByKeycombo[downCombos[0]]?.(keyStates[playedIndex].statuses);
|
|
1422
|
-
keyStates[playedIndex].
|
|
1228
|
+
keyStates[playedIndex].deleteStatus(key);
|
|
1423
1229
|
if (!downCombos.length || !matches) {
|
|
1424
1230
|
onUp?.(toHookApi(api));
|
|
1425
1231
|
return;
|
|
@@ -1429,17 +1235,17 @@ function createKeychord(keychord, options = {}) {
|
|
|
1429
1235
|
if (status === "recognizing" && localStatuses[playedIndex] === "recognized" || status === "recognized") {
|
|
1430
1236
|
metadata.played[playedIndex] = {
|
|
1431
1237
|
...metadata.played[playedIndex],
|
|
1432
|
-
|
|
1238
|
+
keycombo: downCombos[0]
|
|
1433
1239
|
};
|
|
1434
1240
|
}
|
|
1435
1241
|
if (preventsDefaultUnlessDenied)
|
|
1436
1242
|
event.preventDefault();
|
|
1437
|
-
if (playedIndex ===
|
|
1243
|
+
if (playedIndex === narrowedKeycombos.length - 1 && !predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
|
|
1438
1244
|
playedIndex = 0;
|
|
1439
1245
|
for (let i = 0; i < localStatuses.length; i++)
|
|
1440
1246
|
localStatuses[i] = "recognizing";
|
|
1441
|
-
for (const {
|
|
1442
|
-
|
|
1247
|
+
for (const { clearStatuses } of keyStates)
|
|
1248
|
+
clearStatuses();
|
|
1443
1249
|
}
|
|
1444
1250
|
onUp?.(toHookApi(api));
|
|
1445
1251
|
};
|
|
@@ -1449,7 +1255,7 @@ function createKeychord(keychord, options = {}) {
|
|
|
1449
1255
|
denied();
|
|
1450
1256
|
return;
|
|
1451
1257
|
}
|
|
1452
|
-
if (playedIndex ===
|
|
1258
|
+
if (playedIndex === narrowedKeycombos.length - 1) {
|
|
1453
1259
|
recognized();
|
|
1454
1260
|
localStatuses[playedIndex] = "recognized";
|
|
1455
1261
|
return;
|
|
@@ -1458,8 +1264,8 @@ function createKeychord(keychord, options = {}) {
|
|
|
1458
1264
|
};
|
|
1459
1265
|
const visibilitychange = (event, api) => {
|
|
1460
1266
|
if (document.visibilityState === "hidden") {
|
|
1461
|
-
for (const {
|
|
1462
|
-
|
|
1267
|
+
for (const { clearStatuses } of keyStates)
|
|
1268
|
+
clearStatuses();
|
|
1463
1269
|
localStatuses[playedIndex] = "recognizing";
|
|
1464
1270
|
keyStates[playedIndex].cleanup();
|
|
1465
1271
|
playedIndex = 0;
|
|
@@ -1472,30 +1278,56 @@ function createKeychord(keychord, options = {}) {
|
|
|
1472
1278
|
visibilitychange
|
|
1473
1279
|
};
|
|
1474
1280
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1281
|
+
class Keychord extends Listenable {
|
|
1282
|
+
constructor(keycombos, options) {
|
|
1283
|
+
super(
|
|
1284
|
+
"recognizeable",
|
|
1285
|
+
{
|
|
1286
|
+
recognizeable: {
|
|
1287
|
+
effects: createKeychord(keycombos, options)
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
}
|
|
1292
|
+
get metadata() {
|
|
1293
|
+
return this.recognizeable.metadata;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1477
1296
|
|
|
1478
1297
|
function createKonami(options = {}) {
|
|
1479
1298
|
return createKeychord("up up down down left right left right b a enter", options);
|
|
1480
1299
|
}
|
|
1300
|
+
class Konami extends Listenable {
|
|
1301
|
+
constructor(options) {
|
|
1302
|
+
super(
|
|
1303
|
+
"recognizeable",
|
|
1304
|
+
{
|
|
1305
|
+
recognizeable: {
|
|
1306
|
+
effects: createKonami(options)
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
get metadata() {
|
|
1312
|
+
return this.recognizeable.metadata;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1481
1315
|
|
|
1482
|
-
const defaultOptions$
|
|
1316
|
+
const defaultOptions$h = {
|
|
1483
1317
|
minDuration: 0,
|
|
1484
|
-
minDistance: 0
|
|
1485
|
-
getMousemoveTarget: (event) => event.target
|
|
1318
|
+
minDistance: 0
|
|
1486
1319
|
};
|
|
1487
1320
|
function createMousepress(options = {}) {
|
|
1488
1321
|
const {
|
|
1489
1322
|
minDuration,
|
|
1490
1323
|
minDistance,
|
|
1491
|
-
getMousemoveTarget,
|
|
1492
1324
|
onDown,
|
|
1493
1325
|
onLeave,
|
|
1494
1326
|
onMove,
|
|
1495
1327
|
onUp
|
|
1496
|
-
} = { ...defaultOptions$
|
|
1328
|
+
} = { ...defaultOptions$h, ...options }, cleanup = (target) => {
|
|
1497
1329
|
window.cancelAnimationFrame(request);
|
|
1498
|
-
|
|
1330
|
+
target.removeEventListener("mousemove", mousemoveEffect);
|
|
1499
1331
|
};
|
|
1500
1332
|
let request;
|
|
1501
1333
|
let mousemoveEffect;
|
|
@@ -1510,9 +1342,11 @@ function createMousepress(options = {}) {
|
|
|
1510
1342
|
api,
|
|
1511
1343
|
() => mouseStatus === "down",
|
|
1512
1344
|
(newRequest) => request = newRequest,
|
|
1345
|
+
// @ts-expect-error
|
|
1513
1346
|
recognize
|
|
1514
1347
|
);
|
|
1515
|
-
|
|
1348
|
+
const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
|
|
1349
|
+
target.addEventListener("mousemove", mousemoveEffect);
|
|
1516
1350
|
onDown?.(toHookApi(api));
|
|
1517
1351
|
};
|
|
1518
1352
|
const mousemove = (event, api) => {
|
|
@@ -1529,20 +1363,20 @@ function createMousepress(options = {}) {
|
|
|
1529
1363
|
}
|
|
1530
1364
|
};
|
|
1531
1365
|
const mouseleave = (event, api) => {
|
|
1532
|
-
const { denied } = api;
|
|
1366
|
+
const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
|
|
1533
1367
|
if (mouseStatus === "down") {
|
|
1534
1368
|
denied();
|
|
1535
|
-
cleanup(
|
|
1369
|
+
cleanup(target);
|
|
1536
1370
|
mouseStatus = "leave";
|
|
1537
1371
|
}
|
|
1538
1372
|
onLeave?.(toHookApi(api));
|
|
1539
1373
|
};
|
|
1540
1374
|
const mouseup = (event, api) => {
|
|
1541
|
-
const { denied } = api;
|
|
1375
|
+
const { denied, listenInjection: { optionsByType: { mouseup: { target } } } } = api;
|
|
1542
1376
|
if (mouseStatus !== "down")
|
|
1543
1377
|
return;
|
|
1544
1378
|
denied();
|
|
1545
|
-
cleanup(
|
|
1379
|
+
cleanup(target);
|
|
1546
1380
|
mouseStatus = "up";
|
|
1547
1381
|
onUp?.(toHookApi(api));
|
|
1548
1382
|
};
|
|
@@ -1552,26 +1386,39 @@ function createMousepress(options = {}) {
|
|
|
1552
1386
|
mouseup
|
|
1553
1387
|
};
|
|
1554
1388
|
}
|
|
1389
|
+
class Mousepress extends Listenable {
|
|
1390
|
+
constructor(options) {
|
|
1391
|
+
super(
|
|
1392
|
+
"recognizeable",
|
|
1393
|
+
{
|
|
1394
|
+
recognizeable: {
|
|
1395
|
+
effects: createMousepress(options)
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
get metadata() {
|
|
1401
|
+
return this.recognizeable.metadata;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1555
1404
|
|
|
1556
|
-
const defaultOptions$
|
|
1405
|
+
const defaultOptions$g = {
|
|
1557
1406
|
minDuration: 0,
|
|
1558
1407
|
minDistance: 0,
|
|
1559
|
-
minVelocity: 0
|
|
1560
|
-
getMousemoveTarget: (event) => event.target
|
|
1408
|
+
minVelocity: 0
|
|
1561
1409
|
};
|
|
1562
1410
|
function createMouserelease(options = {}) {
|
|
1563
1411
|
const {
|
|
1564
1412
|
minDuration,
|
|
1565
1413
|
minDistance,
|
|
1566
1414
|
minVelocity,
|
|
1567
|
-
getMousemoveTarget,
|
|
1568
1415
|
onDown,
|
|
1569
1416
|
onLeave,
|
|
1570
1417
|
onMove,
|
|
1571
1418
|
onUp
|
|
1572
|
-
} = { ...defaultOptions$
|
|
1419
|
+
} = { ...defaultOptions$g, ...options }, cleanup = (target) => {
|
|
1573
1420
|
window.cancelAnimationFrame(request);
|
|
1574
|
-
|
|
1421
|
+
target.removeEventListener("mousemove", mousemoveEffect);
|
|
1575
1422
|
};
|
|
1576
1423
|
let request;
|
|
1577
1424
|
let mousemoveEffect;
|
|
@@ -1587,7 +1434,8 @@ function createMouserelease(options = {}) {
|
|
|
1587
1434
|
() => mouseStatus === "down",
|
|
1588
1435
|
(newRequest) => request = newRequest
|
|
1589
1436
|
);
|
|
1590
|
-
|
|
1437
|
+
const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
|
|
1438
|
+
target.addEventListener("mousemove", mousemoveEffect);
|
|
1591
1439
|
onDown?.(toHookApi(api));
|
|
1592
1440
|
};
|
|
1593
1441
|
const mousemove = (event, api) => {
|
|
@@ -1595,10 +1443,10 @@ function createMouserelease(options = {}) {
|
|
|
1595
1443
|
onMove?.(toHookApi(api));
|
|
1596
1444
|
};
|
|
1597
1445
|
const mouseleave = (event, api) => {
|
|
1598
|
-
const { denied } = api;
|
|
1446
|
+
const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
|
|
1599
1447
|
if (mouseStatus === "down") {
|
|
1600
1448
|
denied();
|
|
1601
|
-
cleanup(
|
|
1449
|
+
cleanup(target);
|
|
1602
1450
|
mouseStatus = "leave";
|
|
1603
1451
|
}
|
|
1604
1452
|
onLeave?.(toHookApi(api));
|
|
@@ -1607,7 +1455,8 @@ function createMouserelease(options = {}) {
|
|
|
1607
1455
|
if (mouseStatus !== "down")
|
|
1608
1456
|
return;
|
|
1609
1457
|
storePointerMoveMetadata(event, api);
|
|
1610
|
-
|
|
1458
|
+
const { listenInjection: { optionsByType: { mouseup: { target } } } } = api;
|
|
1459
|
+
cleanup(target);
|
|
1611
1460
|
mouseStatus = "up";
|
|
1612
1461
|
recognize(event, api);
|
|
1613
1462
|
onUp?.(toHookApi(api));
|
|
@@ -1626,8 +1475,23 @@ function createMouserelease(options = {}) {
|
|
|
1626
1475
|
mouseup
|
|
1627
1476
|
};
|
|
1628
1477
|
}
|
|
1478
|
+
class Mouserelease extends Listenable {
|
|
1479
|
+
constructor(options) {
|
|
1480
|
+
super(
|
|
1481
|
+
"recognizeable",
|
|
1482
|
+
{
|
|
1483
|
+
recognizeable: {
|
|
1484
|
+
effects: createMouserelease(options)
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
get metadata() {
|
|
1490
|
+
return this.recognizeable.metadata;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1629
1493
|
|
|
1630
|
-
const defaultOptions$
|
|
1494
|
+
const defaultOptions$f = {
|
|
1631
1495
|
minDuration: 0,
|
|
1632
1496
|
minDistance: 0
|
|
1633
1497
|
};
|
|
@@ -1639,7 +1503,7 @@ function createTouchpress(options = {}) {
|
|
|
1639
1503
|
onCancel,
|
|
1640
1504
|
onMove,
|
|
1641
1505
|
onEnd
|
|
1642
|
-
} = { ...defaultOptions$
|
|
1506
|
+
} = { ...defaultOptions$f, ...options }, cleanup = () => {
|
|
1643
1507
|
window.cancelAnimationFrame(request);
|
|
1644
1508
|
};
|
|
1645
1509
|
let request;
|
|
@@ -1660,6 +1524,7 @@ function createTouchpress(options = {}) {
|
|
|
1660
1524
|
api,
|
|
1661
1525
|
() => totalTouches === 1,
|
|
1662
1526
|
(newRequest) => request = newRequest,
|
|
1527
|
+
// @ts-expect-error
|
|
1663
1528
|
recognize
|
|
1664
1529
|
);
|
|
1665
1530
|
onStart?.(toHookApi(api));
|
|
@@ -1699,8 +1564,23 @@ function createTouchpress(options = {}) {
|
|
|
1699
1564
|
touchend
|
|
1700
1565
|
};
|
|
1701
1566
|
}
|
|
1567
|
+
class Touchpress extends Listenable {
|
|
1568
|
+
constructor(options) {
|
|
1569
|
+
super(
|
|
1570
|
+
"recognizeable",
|
|
1571
|
+
{
|
|
1572
|
+
recognizeable: {
|
|
1573
|
+
effects: createTouchpress(options)
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1578
|
+
get metadata() {
|
|
1579
|
+
return this.recognizeable.metadata;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1702
1582
|
|
|
1703
|
-
const defaultOptions$
|
|
1583
|
+
const defaultOptions$e = {
|
|
1704
1584
|
minDuration: 0,
|
|
1705
1585
|
minDistance: 0,
|
|
1706
1586
|
minVelocity: 0
|
|
@@ -1714,7 +1594,7 @@ function createTouchrelease(options = {}) {
|
|
|
1714
1594
|
onCancel,
|
|
1715
1595
|
onMove,
|
|
1716
1596
|
onEnd
|
|
1717
|
-
} = { ...defaultOptions$
|
|
1597
|
+
} = { ...defaultOptions$e, ...options }, cleanup = () => {
|
|
1718
1598
|
window.cancelAnimationFrame(request);
|
|
1719
1599
|
};
|
|
1720
1600
|
let request;
|
|
@@ -1728,867 +1608,1392 @@ function createTouchrelease(options = {}) {
|
|
|
1728
1608
|
onStart?.(toHookApi(api));
|
|
1729
1609
|
return;
|
|
1730
1610
|
}
|
|
1731
|
-
storePointerStartMetadata(event, api);
|
|
1732
|
-
storePointerMoveMetadata(event, api);
|
|
1733
|
-
storePointerTimeMetadata(
|
|
1734
|
-
event,
|
|
1735
|
-
api,
|
|
1736
|
-
() => totalTouches === 1,
|
|
1737
|
-
(newRequest) => request = newRequest
|
|
1738
|
-
);
|
|
1739
|
-
onStart?.(toHookApi(api));
|
|
1740
|
-
};
|
|
1741
|
-
const touchmove = (event, api) => {
|
|
1742
|
-
const { getStatus } = api;
|
|
1743
|
-
if (getStatus() !== "denied")
|
|
1744
|
-
storePointerMoveMetadata(event, api);
|
|
1745
|
-
onMove?.(toHookApi(api));
|
|
1746
|
-
};
|
|
1747
|
-
const touchcancel = (event, api) => {
|
|
1748
|
-
const { denied } = api;
|
|
1749
|
-
cleanup();
|
|
1750
|
-
denied();
|
|
1751
|
-
totalTouches--;
|
|
1752
|
-
onCancel?.(toHookApi(api));
|
|
1611
|
+
storePointerStartMetadata(event, api);
|
|
1612
|
+
storePointerMoveMetadata(event, api);
|
|
1613
|
+
storePointerTimeMetadata(
|
|
1614
|
+
event,
|
|
1615
|
+
api,
|
|
1616
|
+
() => totalTouches === 1,
|
|
1617
|
+
(newRequest) => request = newRequest
|
|
1618
|
+
);
|
|
1619
|
+
onStart?.(toHookApi(api));
|
|
1620
|
+
};
|
|
1621
|
+
const touchmove = (event, api) => {
|
|
1622
|
+
const { getStatus } = api;
|
|
1623
|
+
if (getStatus() !== "denied")
|
|
1624
|
+
storePointerMoveMetadata(event, api);
|
|
1625
|
+
onMove?.(toHookApi(api));
|
|
1626
|
+
};
|
|
1627
|
+
const touchcancel = (event, api) => {
|
|
1628
|
+
const { denied } = api;
|
|
1629
|
+
cleanup();
|
|
1630
|
+
denied();
|
|
1631
|
+
totalTouches--;
|
|
1632
|
+
onCancel?.(toHookApi(api));
|
|
1633
|
+
};
|
|
1634
|
+
const touchend = (event, api) => {
|
|
1635
|
+
const { denied } = api;
|
|
1636
|
+
if (totalTouches !== 1) {
|
|
1637
|
+
cleanup();
|
|
1638
|
+
denied();
|
|
1639
|
+
onEnd?.(toHookApi(api));
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
storePointerMoveMetadata(event, api);
|
|
1643
|
+
cleanup();
|
|
1644
|
+
totalTouches--;
|
|
1645
|
+
recognize(event, api);
|
|
1646
|
+
onEnd?.(toHookApi(api));
|
|
1647
|
+
};
|
|
1648
|
+
const recognize = (event, api) => {
|
|
1649
|
+
const { getMetadata, recognized, denied } = api, metadata = getMetadata();
|
|
1650
|
+
if (metadata.duration >= minDuration && metadata.distance.straight.fromStart >= minDistance && metadata.velocity >= minVelocity) {
|
|
1651
|
+
recognized();
|
|
1652
|
+
} else {
|
|
1653
|
+
denied();
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
return {
|
|
1657
|
+
touchstart,
|
|
1658
|
+
touchmove,
|
|
1659
|
+
touchcancel,
|
|
1660
|
+
touchend
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
class Touchrelease extends Listenable {
|
|
1664
|
+
constructor(options) {
|
|
1665
|
+
super(
|
|
1666
|
+
"recognizeable",
|
|
1667
|
+
{
|
|
1668
|
+
recognizeable: {
|
|
1669
|
+
effects: createTouchrelease(options)
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
get metadata() {
|
|
1675
|
+
return this.recognizeable.metadata;
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
function createRoot(graph) {
|
|
1680
|
+
const toIndegree = createIndegree(graph);
|
|
1681
|
+
return (node) => toIndegree(node) === 0;
|
|
1682
|
+
}
|
|
1683
|
+
function createTerminal(graph) {
|
|
1684
|
+
const toOutdegree = createOutdegree(graph);
|
|
1685
|
+
return (node) => toOutdegree(node) === 0;
|
|
1686
|
+
}
|
|
1687
|
+
function createChildren(graph) {
|
|
1688
|
+
return function* (node) {
|
|
1689
|
+
const outgoing = createOutgoing(graph)(node);
|
|
1690
|
+
for (const edge of outgoing)
|
|
1691
|
+
yield edge.to;
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
function createIndegree(graph) {
|
|
1695
|
+
const toIncoming = createIncoming(graph);
|
|
1696
|
+
return (node) => pipe(
|
|
1697
|
+
toIncoming,
|
|
1698
|
+
toLength()
|
|
1699
|
+
)(node);
|
|
1700
|
+
}
|
|
1701
|
+
function createOutdegree(graph) {
|
|
1702
|
+
const toOutgoing = createOutgoing(graph);
|
|
1703
|
+
return (node) => pipe(
|
|
1704
|
+
toOutgoing,
|
|
1705
|
+
toLength()
|
|
1706
|
+
)(node);
|
|
1707
|
+
}
|
|
1708
|
+
function createIncoming(graph) {
|
|
1709
|
+
const { edges } = graph;
|
|
1710
|
+
return function* (node) {
|
|
1711
|
+
yield* filter(
|
|
1712
|
+
({ to }) => to === node
|
|
1713
|
+
)(edges);
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function createOutgoing(graph) {
|
|
1717
|
+
const { edges } = graph;
|
|
1718
|
+
return function* (node) {
|
|
1719
|
+
yield* filter(
|
|
1720
|
+
({ from }) => from === node
|
|
1721
|
+
)(edges);
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
function createOnlyChild(graph) {
|
|
1725
|
+
const toTotalSiblings = createTotalSiblings(graph);
|
|
1726
|
+
return (node) => toTotalSiblings(node) === 0;
|
|
1727
|
+
}
|
|
1728
|
+
function createTotalSiblings(graph) {
|
|
1729
|
+
const toSiblings = createSiblings(graph);
|
|
1730
|
+
return (node) => pipe(
|
|
1731
|
+
toSiblings,
|
|
1732
|
+
toLength()
|
|
1733
|
+
)(node);
|
|
1734
|
+
}
|
|
1735
|
+
function createSiblings(graph) {
|
|
1736
|
+
const { edges } = graph;
|
|
1737
|
+
return function* (node) {
|
|
1738
|
+
const parents = pipe(
|
|
1739
|
+
filter(
|
|
1740
|
+
({ to }) => to === node
|
|
1741
|
+
),
|
|
1742
|
+
map(
|
|
1743
|
+
({ from }) => from
|
|
1744
|
+
)
|
|
1745
|
+
)(edges);
|
|
1746
|
+
for (const parent of parents) {
|
|
1747
|
+
yield* pipe(
|
|
1748
|
+
filter(
|
|
1749
|
+
({ from, to }) => from === parent && to !== node
|
|
1750
|
+
),
|
|
1751
|
+
map(
|
|
1752
|
+
({ to }) => to
|
|
1753
|
+
)
|
|
1754
|
+
)(edges);
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
function createFind(node) {
|
|
1760
|
+
return (tree) => {
|
|
1761
|
+
for (const treeNode of tree) {
|
|
1762
|
+
if (treeNode.node === node)
|
|
1763
|
+
return treeNode;
|
|
1764
|
+
const found = createFind(node)(treeNode.children);
|
|
1765
|
+
if (found)
|
|
1766
|
+
return found;
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
function createPath$2(directedAcyclic, config) {
|
|
1772
|
+
const { predicatePathable, toTraversalCandidates } = config, firstRoot = pipe(
|
|
1773
|
+
createRoots(),
|
|
1774
|
+
at(0)
|
|
1775
|
+
)(directedAcyclic);
|
|
1776
|
+
return (state) => {
|
|
1777
|
+
const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
|
|
1778
|
+
while (getLastPathable() && getLastStatus() === "set") {
|
|
1779
|
+
const edge = pipe(
|
|
1780
|
+
toTraversalCandidates,
|
|
1781
|
+
find(
|
|
1782
|
+
({ predicateShouldTraverse }) => predicateShouldTraverse(state)
|
|
1783
|
+
)
|
|
1784
|
+
)(path);
|
|
1785
|
+
path.push(edge.to);
|
|
1786
|
+
}
|
|
1787
|
+
return path;
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
function createLayers$1(options = {}) {
|
|
1792
|
+
const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
|
|
1793
|
+
return function* toLayers(directedAcyclic) {
|
|
1794
|
+
const layers = [];
|
|
1795
|
+
for (const { path } of toSteps(directedAcyclic)) {
|
|
1796
|
+
const node = path.at(-1), depth = path.length - 1;
|
|
1797
|
+
if (!layers[depth] && depth > 0)
|
|
1798
|
+
yield layers[depth - 1];
|
|
1799
|
+
(layers[depth] || (layers[depth] = [])).push(node);
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
function createTree$2(options = {}) {
|
|
1804
|
+
const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
|
|
1805
|
+
return (directedAcyclic) => {
|
|
1806
|
+
const firstRoot = pipe(
|
|
1807
|
+
createRoots(),
|
|
1808
|
+
at(0)
|
|
1809
|
+
)(directedAcyclic), tree = [];
|
|
1810
|
+
tree.push({
|
|
1811
|
+
node: firstRoot,
|
|
1812
|
+
children: []
|
|
1813
|
+
});
|
|
1814
|
+
for (const { path } of toSteps(directedAcyclic)) {
|
|
1815
|
+
const node = path.at(-1), parent = path.at(-2);
|
|
1816
|
+
if (parent) {
|
|
1817
|
+
const parentTreeNode = createFind(parent)(tree);
|
|
1818
|
+
if (parentTreeNode) {
|
|
1819
|
+
parentTreeNode.children.push({
|
|
1820
|
+
node,
|
|
1821
|
+
children: []
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
return tree;
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
const defaultCreateDepthFirstStepsOptions = {
|
|
1830
|
+
getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered
|
|
1831
|
+
};
|
|
1832
|
+
function createDepthFirstSteps$2(options = {}) {
|
|
1833
|
+
return createSteps$1(
|
|
1834
|
+
createConfigureDepthFirstSteps(options),
|
|
1835
|
+
options
|
|
1836
|
+
);
|
|
1837
|
+
}
|
|
1838
|
+
function createConfigureDepthFirstSteps(options) {
|
|
1839
|
+
const { getSetStateValue: getSetStateValueOption } = {
|
|
1840
|
+
...defaultCreateDepthFirstStepsOptions,
|
|
1841
|
+
...options
|
|
1842
|
+
};
|
|
1843
|
+
return function(directedAcyclic) {
|
|
1844
|
+
const getSetStateValue = (node) => getSetStateValueOption({
|
|
1845
|
+
node,
|
|
1846
|
+
totalChildrenDiscovered: totalChildrenDiscoveredByNode[node]
|
|
1847
|
+
}), stepFromEffect = (node) => totalChildrenDiscoveredByNode[node]++, predicateSteppable = (node) => !predicateTerminal(node), predicateTerminal = createTerminal(directedAcyclic), predicateExhausted = (node) => totalChildrenDiscoveredByNode[node] === toTotalSiblings(node), toTotalSiblings = createOutdegree(directedAcyclic), totalChildrenDiscoveredByNode = createReduce(
|
|
1848
|
+
(totalChildrenDiscoveredByNode2, node) => {
|
|
1849
|
+
totalChildrenDiscoveredByNode2[node] = 0;
|
|
1850
|
+
return totalChildrenDiscoveredByNode2;
|
|
1851
|
+
},
|
|
1852
|
+
{}
|
|
1853
|
+
)(directedAcyclic.nodes);
|
|
1854
|
+
return {
|
|
1855
|
+
getSetStateValue,
|
|
1856
|
+
stepFromEffect,
|
|
1857
|
+
predicateSteppable,
|
|
1858
|
+
predicateExhausted,
|
|
1859
|
+
createPath: createDepthPathConfig(directedAcyclic)
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
const defaultCreateStepsOptions$1 = {
|
|
1864
|
+
kind: "directed acyclic"
|
|
1865
|
+
};
|
|
1866
|
+
function createSteps$1(configure, options = {}) {
|
|
1867
|
+
return function* (directedAcyclic) {
|
|
1868
|
+
const {
|
|
1869
|
+
getSetStateValue,
|
|
1870
|
+
stepFromEffect,
|
|
1871
|
+
predicateSteppable,
|
|
1872
|
+
predicateExhausted,
|
|
1873
|
+
createPath: createPathConfig
|
|
1874
|
+
} = configure(directedAcyclic), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclic, toPath = createPath$2(directedAcyclic, createPathConfig), roots = pipe(
|
|
1875
|
+
createRoots({ kind }),
|
|
1876
|
+
toArray()
|
|
1877
|
+
)(directedAcyclic), state = {};
|
|
1878
|
+
for (const node of nodes) {
|
|
1879
|
+
state[node] = {
|
|
1880
|
+
status: "unset",
|
|
1881
|
+
value: void 0
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
let location = root || at(0)(roots);
|
|
1885
|
+
const path = toPath(state);
|
|
1886
|
+
yield { path, state: JSON.parse(JSON.stringify(state)) };
|
|
1887
|
+
function* toStep() {
|
|
1888
|
+
if (predicateExhausted(location)) {
|
|
1889
|
+
if (includes(location)(roots))
|
|
1890
|
+
return;
|
|
1891
|
+
state[location].status = "unset";
|
|
1892
|
+
delete state[location].value;
|
|
1893
|
+
const path3 = toPath(state);
|
|
1894
|
+
location = path3.at(-2);
|
|
1895
|
+
yield* toStep();
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
state[location].status = "set";
|
|
1899
|
+
state[location].value = getSetStateValue(location);
|
|
1900
|
+
const path2 = toPath(state);
|
|
1901
|
+
yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
|
|
1902
|
+
stepFromEffect(location);
|
|
1903
|
+
const newLocation = path2.at(-1);
|
|
1904
|
+
if (predicateSteppable(newLocation))
|
|
1905
|
+
location = newLocation;
|
|
1906
|
+
yield* toStep();
|
|
1907
|
+
}
|
|
1908
|
+
yield* toStep();
|
|
1753
1909
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1910
|
+
}
|
|
1911
|
+
function createRoots(options = {}) {
|
|
1912
|
+
return function* (directedAcyclic) {
|
|
1913
|
+
const { nodes } = directedAcyclic, predicateRoot = createRoot(directedAcyclic);
|
|
1914
|
+
for (const node of nodes) {
|
|
1915
|
+
if (predicateRoot(node))
|
|
1916
|
+
yield node;
|
|
1917
|
+
if (options.kind === "arborescence")
|
|
1918
|
+
break;
|
|
1761
1919
|
}
|
|
1762
|
-
storePointerMoveMetadata(event, api);
|
|
1763
|
-
cleanup();
|
|
1764
|
-
totalTouches--;
|
|
1765
|
-
recognize(event, api);
|
|
1766
|
-
onEnd?.(toHookApi(api));
|
|
1767
1920
|
};
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
function createCommonAncestors$2(directedAcyclic) {
|
|
1924
|
+
const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
|
|
1925
|
+
return function* (a, b) {
|
|
1926
|
+
for (const { path: aPath } of toNodeDepthFirstSteps(a)) {
|
|
1927
|
+
for (const { path: bPath } of toNodeDepthFirstSteps(b)) {
|
|
1928
|
+
for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
|
|
1929
|
+
for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
|
|
1930
|
+
if (aPath[aPathIndex] === bPath[bPathIndex] && !includes(aPath[aPathIndex])([a, b])) {
|
|
1931
|
+
yield {
|
|
1932
|
+
node: aPath[aPathIndex],
|
|
1933
|
+
distances: {
|
|
1934
|
+
[a]: aPath.length - aPathIndex - 1,
|
|
1935
|
+
[b]: bPath.length - bPathIndex - 1
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1774
1942
|
}
|
|
1775
1943
|
};
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1944
|
+
}
|
|
1945
|
+
function createAncestor$2(directedAcyclic) {
|
|
1946
|
+
const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
|
|
1947
|
+
return function(descendant, ancestor) {
|
|
1948
|
+
return pipe(
|
|
1949
|
+
toNodeDepthFirstSteps,
|
|
1950
|
+
some(({ path }) => includes(ancestor)(path))
|
|
1951
|
+
)(descendant);
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
function createNodeDepthFirstSteps$2(directedAcyclic, options = {}) {
|
|
1955
|
+
const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
|
|
1956
|
+
return function* (node) {
|
|
1957
|
+
yield* pipe(
|
|
1958
|
+
toSteps,
|
|
1959
|
+
filter(({ path }) => path.at(-1) === node)
|
|
1960
|
+
)(directedAcyclic);
|
|
1781
1961
|
};
|
|
1782
1962
|
}
|
|
1783
1963
|
|
|
1784
|
-
const
|
|
1785
|
-
|
|
1964
|
+
const defaultCreateStepsOptions = {
|
|
1965
|
+
priorityBranch: false,
|
|
1966
|
+
kind: "directed acyclic"
|
|
1786
1967
|
};
|
|
1787
|
-
function
|
|
1788
|
-
|
|
1789
|
-
...defaultOptions$9,
|
|
1968
|
+
function createTree$1(options = {}) {
|
|
1969
|
+
const withDefaults = {
|
|
1790
1970
|
...options,
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1971
|
+
createDepthFirstSteps: {
|
|
1972
|
+
...defaultCreateStepsOptions,
|
|
1973
|
+
...options.createDepthFirstSteps
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
return createTree$2(withDefaults);
|
|
1977
|
+
}
|
|
1978
|
+
function createCommonAncestors$1(...params) {
|
|
1979
|
+
return createCommonAncestors$2(...params);
|
|
1980
|
+
}
|
|
1981
|
+
function createAncestor$1(...params) {
|
|
1982
|
+
return createAncestor$2(...params);
|
|
1983
|
+
}
|
|
1984
|
+
function createNodeDepthFirstSteps$1(decisionTree, options = {}) {
|
|
1985
|
+
const withDefaults = {
|
|
1986
|
+
...options,
|
|
1987
|
+
createDepthFirstSteps: {
|
|
1988
|
+
...defaultCreateStepsOptions,
|
|
1989
|
+
...options.createDepthFirstSteps
|
|
1798
1990
|
}
|
|
1991
|
+
};
|
|
1992
|
+
return createNodeDepthFirstSteps$2(
|
|
1993
|
+
decisionTree,
|
|
1994
|
+
withDefaults
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
function createDepthFirstSteps$1(options) {
|
|
1998
|
+
const { priorityBranch } = { ...defaultCreateStepsOptions, ...options }, configureDepthFirstSteps = createConfigureDepthFirstSteps({
|
|
1999
|
+
getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered === 0 ? priorityBranch : !priorityBranch
|
|
1799
2000
|
});
|
|
2001
|
+
return createSteps$1(configureDepthFirstSteps, options);
|
|
1800
2002
|
}
|
|
1801
|
-
function
|
|
1802
|
-
return
|
|
2003
|
+
function createPath$1(...params) {
|
|
2004
|
+
return createPath$2(...params);
|
|
1803
2005
|
}
|
|
1804
2006
|
|
|
1805
|
-
function
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
for (const keycombo of narrowedKeycombos) {
|
|
1819
|
-
predicates.push([
|
|
1820
|
-
keycombo,
|
|
1821
|
-
createPredicateKeycomboDown(
|
|
1822
|
-
keycombo,
|
|
1823
|
-
createPredicateKeycomboDownOptions
|
|
2007
|
+
function createPath(directedAcyclicAsync, config) {
|
|
2008
|
+
const { predicatePathable, toTraversalCandidates } = config, firstRoot = pipe(
|
|
2009
|
+
createRoots(),
|
|
2010
|
+
at(0)
|
|
2011
|
+
)(directedAcyclicAsync);
|
|
2012
|
+
return async (state) => {
|
|
2013
|
+
const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
|
|
2014
|
+
while (getLastPathable() && getLastStatus() === "set") {
|
|
2015
|
+
const edge = await pipe(
|
|
2016
|
+
toTraversalCandidates,
|
|
2017
|
+
toArray(),
|
|
2018
|
+
createFindAsync(
|
|
2019
|
+
async ({ predicateShouldTraverse }) => await predicateShouldTraverse(state)
|
|
1824
2020
|
)
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
return predicates;
|
|
1828
|
-
})(), createPredicateKeycomboMatchOptions = { ...createPredicateKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
|
|
1829
|
-
const predicates = {};
|
|
1830
|
-
for (const keycombo of narrowedKeycombos) {
|
|
1831
|
-
predicates[keycombo] = createPredicateKeycomboMatch$1(
|
|
1832
|
-
keycombo,
|
|
1833
|
-
createPredicateKeycomboMatchOptions
|
|
1834
|
-
);
|
|
2021
|
+
)(path);
|
|
2022
|
+
path.push(edge.to);
|
|
1835
2023
|
}
|
|
1836
|
-
return
|
|
1837
|
-
})(), validAliases = pipe(
|
|
1838
|
-
flatMap(fromComboToAliases),
|
|
1839
|
-
unique(),
|
|
1840
|
-
toArray()
|
|
1841
|
-
)(narrowedKeycombos), getDownCombos = () => pipe(
|
|
1842
|
-
filter(([, predicate]) => predicate(statuses)),
|
|
1843
|
-
map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
|
|
1844
|
-
sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
|
|
1845
|
-
map(([keycombo]) => keycombo),
|
|
1846
|
-
toArray()
|
|
1847
|
-
)(downPredicatesByKeycombo), predicateValid = (event) => {
|
|
1848
|
-
const aliases = toAliases(event);
|
|
1849
|
-
return some(
|
|
1850
|
-
(validAlias) => includes(validAlias)(aliases)
|
|
1851
|
-
)(validAliases);
|
|
1852
|
-
}, cleanup = () => {
|
|
1853
|
-
window.cancelAnimationFrame(getRequest());
|
|
1854
|
-
}, statuses = createKeyStatuses();
|
|
1855
|
-
return {
|
|
1856
|
-
narrowedKeycombos,
|
|
1857
|
-
createPredicateKeycomboDownOptions,
|
|
1858
|
-
downPredicatesByKeycombo,
|
|
1859
|
-
createPredicateKeycomboMatchOptions,
|
|
1860
|
-
matchPredicatesByKeycombo,
|
|
1861
|
-
validAliases,
|
|
1862
|
-
getDownCombos,
|
|
1863
|
-
predicateValid,
|
|
1864
|
-
cleanup,
|
|
1865
|
-
statuses
|
|
2024
|
+
return path;
|
|
1866
2025
|
};
|
|
1867
2026
|
}
|
|
1868
2027
|
|
|
1869
|
-
function
|
|
1870
|
-
|
|
1871
|
-
|
|
2028
|
+
function createLayers(options = {}) {
|
|
2029
|
+
const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
|
|
2030
|
+
return async function toLayers(directedAcyclicAsync) {
|
|
2031
|
+
const layers = [];
|
|
2032
|
+
for await (const { path } of toSteps(directedAcyclicAsync)) {
|
|
2033
|
+
const node = path.at(-1), depth = path.length - 1;
|
|
2034
|
+
(layers[depth] || (layers[depth] = [])).push(node);
|
|
2035
|
+
}
|
|
2036
|
+
return layers;
|
|
1872
2037
|
};
|
|
1873
2038
|
}
|
|
1874
|
-
|
|
1875
|
-
const
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
)
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
2039
|
+
function createTree(options = {}) {
|
|
2040
|
+
const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
|
|
2041
|
+
return async function toTree(directedAcyclicAsync) {
|
|
2042
|
+
const firstRoot = pipe(
|
|
2043
|
+
createRoots(),
|
|
2044
|
+
at(0)
|
|
2045
|
+
)(directedAcyclicAsync), tree = [];
|
|
2046
|
+
tree.push({
|
|
2047
|
+
node: firstRoot,
|
|
2048
|
+
children: []
|
|
2049
|
+
});
|
|
2050
|
+
for await (const { path } of toSteps(directedAcyclicAsync)) {
|
|
2051
|
+
const node = path.at(-1), parent = path.at(-2);
|
|
2052
|
+
if (parent) {
|
|
2053
|
+
const parentTreeNode = createFind(parent)(tree);
|
|
2054
|
+
if (parentTreeNode) {
|
|
2055
|
+
parentTreeNode.children.push({
|
|
2056
|
+
node,
|
|
2057
|
+
children: []
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return tree;
|
|
2063
|
+
};
|
|
1882
2064
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
2065
|
+
function createDepthFirstSteps(options = {}) {
|
|
2066
|
+
return createSteps(
|
|
2067
|
+
createConfigureDepthFirstSteps(options),
|
|
2068
|
+
options
|
|
2069
|
+
);
|
|
1887
2070
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
metadata: getMetadata()
|
|
2071
|
+
function createSteps(configure, options = {}) {
|
|
2072
|
+
return async function* (directedAcyclicAsync) {
|
|
2073
|
+
const {
|
|
2074
|
+
getSetStateValue,
|
|
2075
|
+
stepFromEffect,
|
|
2076
|
+
predicateSteppable,
|
|
2077
|
+
predicateExhausted,
|
|
2078
|
+
createPath: createPathConfig
|
|
2079
|
+
} = configure(directedAcyclicAsync), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclicAsync, toPath = createPath(directedAcyclicAsync, createPathConfig), roots = pipe(
|
|
2080
|
+
createRoots({ kind }),
|
|
2081
|
+
toArray()
|
|
2082
|
+
)(directedAcyclicAsync), state = {};
|
|
2083
|
+
for (const node of nodes) {
|
|
2084
|
+
state[node] = {
|
|
2085
|
+
status: "unset",
|
|
2086
|
+
value: void 0
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
let location = root || at(0)(roots);
|
|
2090
|
+
const path = await toPath(state);
|
|
2091
|
+
yield { path, state: JSON.parse(JSON.stringify(state)) };
|
|
2092
|
+
async function* toStep() {
|
|
2093
|
+
if (predicateExhausted(location)) {
|
|
2094
|
+
if (includes(location)(roots))
|
|
2095
|
+
return;
|
|
2096
|
+
state[location].status = "unset";
|
|
2097
|
+
delete state[location].value;
|
|
2098
|
+
const path3 = await toPath(state);
|
|
2099
|
+
location = path3.at(-2);
|
|
2100
|
+
yield* await toStep();
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
state[location].status = "set";
|
|
2104
|
+
state[location].value = getSetStateValue(location);
|
|
2105
|
+
const path2 = await toPath(state);
|
|
2106
|
+
yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
|
|
2107
|
+
stepFromEffect(location);
|
|
2108
|
+
const newLocation = path2.at(-1);
|
|
2109
|
+
if (predicateSteppable(newLocation))
|
|
2110
|
+
location = newLocation;
|
|
2111
|
+
yield* await toStep();
|
|
2112
|
+
}
|
|
2113
|
+
yield* await toStep();
|
|
1932
2114
|
};
|
|
1933
2115
|
}
|
|
1934
2116
|
|
|
1935
|
-
function
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2117
|
+
function createCommonAncestors(directedAcyclicAsync) {
|
|
2118
|
+
const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
|
|
2119
|
+
return async function* (a, b) {
|
|
2120
|
+
for await (const { path: aPath } of toNodeDepthFirstSteps(a)) {
|
|
2121
|
+
for await (const { path: bPath } of toNodeDepthFirstSteps(b)) {
|
|
2122
|
+
for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
|
|
2123
|
+
for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
|
|
2124
|
+
if (aPath[aPathIndex] === bPath[bPathIndex] && !includes(aPath[aPathIndex])([a, b])) {
|
|
2125
|
+
yield {
|
|
2126
|
+
node: aPath[aPathIndex],
|
|
2127
|
+
distances: {
|
|
2128
|
+
[a]: aPath.length - aPathIndex - 1,
|
|
2129
|
+
[b]: bPath.length - bPathIndex - 1
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
1939
2137
|
};
|
|
1940
2138
|
}
|
|
1941
|
-
function
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2139
|
+
function createAncestor(directedAcyclicAsync) {
|
|
2140
|
+
const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
|
|
2141
|
+
return async function(descendant, ancestor) {
|
|
2142
|
+
return await pipe(
|
|
2143
|
+
toNodeDepthFirstSteps,
|
|
2144
|
+
some(({ path }) => includes(ancestor)(path))
|
|
2145
|
+
)(descendant);
|
|
1945
2146
|
};
|
|
1946
2147
|
}
|
|
1947
|
-
function
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
2148
|
+
function createNodeDepthFirstSteps(directedAcyclicAsync, options = {}) {
|
|
2149
|
+
const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
|
|
2150
|
+
return async function* (node) {
|
|
2151
|
+
yield* await pipe(
|
|
2152
|
+
toSteps,
|
|
2153
|
+
filter(({ path }) => path.at(-1) === node)
|
|
2154
|
+
)(directedAcyclicAsync);
|
|
1951
2155
|
};
|
|
1952
2156
|
}
|
|
1953
2157
|
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2158
|
+
const defaultOptions$d = {
|
|
2159
|
+
predicatesElement: false,
|
|
2160
|
+
// Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
|
|
2161
|
+
tabbableSelector: join(':not([hidden]):not([tabindex="-1"]),')([
|
|
2162
|
+
"input:not([disabled]):not([type=hidden])",
|
|
2163
|
+
"select:not([disabled])",
|
|
2164
|
+
"textarea:not([disabled])",
|
|
2165
|
+
"button:not([disabled])",
|
|
2166
|
+
"a[href]",
|
|
2167
|
+
"area[href]",
|
|
2168
|
+
"summary",
|
|
2169
|
+
"iframe",
|
|
2170
|
+
"object",
|
|
2171
|
+
"embed",
|
|
2172
|
+
"audio[controls]",
|
|
2173
|
+
"video[controls]",
|
|
2174
|
+
"[contenteditable]",
|
|
2175
|
+
"[tabindex]:not([disabled])"
|
|
2176
|
+
])
|
|
2177
|
+
};
|
|
2178
|
+
function createFocusable(order, options = {}) {
|
|
2179
|
+
const { predicatesElement, tabbableSelector } = { ...defaultOptions$d, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
|
|
2180
|
+
return (element) => {
|
|
2181
|
+
if (predicatesElement && predicateFocusable(element))
|
|
2182
|
+
return element;
|
|
2183
|
+
switch (order) {
|
|
2184
|
+
case "first":
|
|
2185
|
+
for (let i = 0; i < element.children.length; i++) {
|
|
2186
|
+
const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
|
|
2187
|
+
if (focusable)
|
|
2188
|
+
return focusable;
|
|
2189
|
+
}
|
|
2190
|
+
break;
|
|
2191
|
+
case "last":
|
|
2192
|
+
for (let i = element.children.length - 1; i > -1; i--) {
|
|
2193
|
+
const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
|
|
2194
|
+
if (focusable)
|
|
2195
|
+
return focusable;
|
|
2196
|
+
}
|
|
2197
|
+
break;
|
|
2198
|
+
}
|
|
1959
2199
|
};
|
|
1960
2200
|
}
|
|
2201
|
+
function createComputedStyle(pseudoElement) {
|
|
2202
|
+
return (element) => getComputedStyle(element, pseudoElement);
|
|
2203
|
+
}
|
|
1961
2204
|
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
end: 0
|
|
1966
|
-
},
|
|
1967
|
-
duration: 0
|
|
2205
|
+
const defaultOptions$c = {
|
|
2206
|
+
toCode: (alias) => fromAliasToCode(alias),
|
|
2207
|
+
toAliases: (descriptor) => fromKeyboardEventDescriptorToAliases(descriptor)
|
|
1968
2208
|
};
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2209
|
+
const createKeycomboMatch$1 = (keycombo, options = {}) => {
|
|
2210
|
+
const { toLonghand, toCode, toAliases: fromDescriptorToAliases } = { ...defaultOptions$c, ...options }, fromComboToAliases = createAliases({ toLonghand }), aliases = fromComboToAliases(keycombo), codes = createMap(toCode)(aliases), implicitModifierAliases = (() => {
|
|
2211
|
+
const implicitModifierAliases2 = [];
|
|
2212
|
+
for (const code of codes) {
|
|
2213
|
+
const implicitModifier = find(
|
|
2214
|
+
(modifier) => code.includes(modifier)
|
|
2215
|
+
)(modifiers);
|
|
2216
|
+
if (implicitModifier)
|
|
2217
|
+
implicitModifierAliases2.push(implicitModifier.toLowerCase());
|
|
2218
|
+
}
|
|
2219
|
+
return implicitModifierAliases2;
|
|
2220
|
+
})();
|
|
2221
|
+
return (event) => {
|
|
2222
|
+
const statuses = [];
|
|
2223
|
+
createSet(fromEventToKeyStatusCode(event), "down")(statuses);
|
|
2224
|
+
for (const modifier of modifiers) {
|
|
2225
|
+
if (event[`${modifier.toLowerCase()}Key`])
|
|
2226
|
+
createSet(modifier, "down")(statuses);
|
|
2227
|
+
}
|
|
2228
|
+
const events = createMap(
|
|
2229
|
+
([code]) => {
|
|
2230
|
+
const e = { code };
|
|
2231
|
+
for (const modifier of modifiers) {
|
|
2232
|
+
e[`${modifier.toLowerCase()}Key`] = event[`${modifier.toLowerCase()}Key`];
|
|
2233
|
+
}
|
|
2234
|
+
return e;
|
|
1994
2235
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2236
|
+
)(statuses);
|
|
2237
|
+
return every(
|
|
2238
|
+
(code) => createValue(
|
|
2239
|
+
code,
|
|
2240
|
+
{ predicateKey: createCode(code) }
|
|
2241
|
+
)(statuses) === "down"
|
|
2242
|
+
)(codes) && every(
|
|
2243
|
+
(e) => pipe(
|
|
2244
|
+
fromDescriptorToAliases,
|
|
2245
|
+
map(fromComboToAliases),
|
|
2246
|
+
some(
|
|
2247
|
+
(longhandAliases) => every(
|
|
2248
|
+
(longhandAlias) => includes(longhandAlias)(aliases) || includes(longhandAlias)(implicitModifierAliases)
|
|
2249
|
+
)(longhandAliases)
|
|
2250
|
+
)
|
|
2251
|
+
)(e)
|
|
2252
|
+
)(events);
|
|
1998
2253
|
};
|
|
1999
|
-
storeDuration();
|
|
2000
|
-
}
|
|
2001
|
-
|
|
2002
|
-
const initialMetadata$2 = {
|
|
2003
|
-
points: {
|
|
2004
|
-
start: { x: 0, y: 0 },
|
|
2005
|
-
end: { x: 0, y: 0 }
|
|
2006
|
-
}
|
|
2007
2254
|
};
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2255
|
+
|
|
2256
|
+
function createClamp(min, max) {
|
|
2257
|
+
return (number) => {
|
|
2258
|
+
const maxed = Math.max(number, min);
|
|
2259
|
+
return Math.min(maxed, max);
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
function createDetermine(potentialities) {
|
|
2263
|
+
const predicates = createMap(
|
|
2264
|
+
({ outcome, probability }, index) => {
|
|
2265
|
+
const lowerBound = index === 0 ? 0 : pipe(
|
|
2266
|
+
slice(0, index - 1),
|
|
2267
|
+
reduce(
|
|
2268
|
+
(lowerBound2, { probability: probability2 }) => lowerBound2 + probability2,
|
|
2269
|
+
0
|
|
2270
|
+
)
|
|
2271
|
+
)(potentialities), upperBound = lowerBound + probability;
|
|
2272
|
+
return {
|
|
2273
|
+
outcome,
|
|
2274
|
+
predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
)(potentialities);
|
|
2278
|
+
return (determinant) => find(
|
|
2279
|
+
({ predicate }) => predicate(determinant)
|
|
2280
|
+
)(predicates).outcome;
|
|
2281
|
+
}
|
|
2282
|
+
function createGreater(threshold) {
|
|
2283
|
+
return (number) => number > threshold;
|
|
2284
|
+
}
|
|
2285
|
+
function createGreaterOrEqual(threshold) {
|
|
2286
|
+
return (number) => number >= threshold;
|
|
2287
|
+
}
|
|
2288
|
+
function createLessOrEqual(threshold) {
|
|
2289
|
+
return (number) => number <= threshold;
|
|
2290
|
+
}
|
|
2291
|
+
function createLess(threshold) {
|
|
2292
|
+
return (number) => number < threshold;
|
|
2015
2293
|
}
|
|
2016
2294
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
fromStart: 0,
|
|
2029
|
-
fromPrevious: 0
|
|
2295
|
+
function createValue$1(key) {
|
|
2296
|
+
return (object) => object[key];
|
|
2297
|
+
}
|
|
2298
|
+
function createHas(key) {
|
|
2299
|
+
return (object) => key in object;
|
|
2300
|
+
}
|
|
2301
|
+
function createKeys() {
|
|
2302
|
+
return (object) => {
|
|
2303
|
+
const keys = [];
|
|
2304
|
+
for (const key in object) {
|
|
2305
|
+
keys.push(key);
|
|
2030
2306
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
function storePointerMoveMetadata(event, api) {
|
|
2042
|
-
const { getMetadata } = api, metadata = getMetadata();
|
|
2043
|
-
if (!metadata.distance) {
|
|
2044
|
-
metadata.distance = createClone()(initialMetadata$1.distance);
|
|
2045
|
-
metadata.angle = createClone()(initialMetadata$1.angle);
|
|
2046
|
-
metadata.direction = createClone()(initialMetadata$1.direction);
|
|
2047
|
-
}
|
|
2048
|
-
const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
|
|
2049
|
-
if (event instanceof MouseEvent) {
|
|
2050
|
-
return toMousePoint(event);
|
|
2307
|
+
return keys;
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
function createEntries() {
|
|
2311
|
+
return (object) => {
|
|
2312
|
+
const entries = [];
|
|
2313
|
+
for (const key in object) {
|
|
2314
|
+
entries.push([key, object[key]]);
|
|
2051
2315
|
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2316
|
+
return entries;
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
function createEvery(predicate) {
|
|
2320
|
+
return (object) => {
|
|
2321
|
+
for (const key in object) {
|
|
2322
|
+
if (!predicate(key, object[key])) {
|
|
2323
|
+
return false;
|
|
2055
2324
|
}
|
|
2056
|
-
return toTouchEndPoint(event);
|
|
2057
2325
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
metadata.distance.horizontal.fromStart = newX - startX;
|
|
2076
|
-
metadata.distance.vertical.fromStart = newY - startY;
|
|
2077
|
-
metadata.angle.fromStart = angleFromStart;
|
|
2078
|
-
metadata.direction.fromStart = toDirection(angleFromStart.degrees);
|
|
2079
|
-
metadata.points.end = { x: newX, y: newY };
|
|
2326
|
+
return true;
|
|
2327
|
+
};
|
|
2328
|
+
}
|
|
2329
|
+
function createSome(predicate) {
|
|
2330
|
+
return (object) => {
|
|
2331
|
+
for (const key in object) {
|
|
2332
|
+
if (predicate(key, object[key]))
|
|
2333
|
+
return true;
|
|
2334
|
+
}
|
|
2335
|
+
return false;
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
function createDeepMerge(override) {
|
|
2339
|
+
return (object) => {
|
|
2340
|
+
const merged = createClone()(object);
|
|
2341
|
+
return merge(merged, override || {});
|
|
2342
|
+
};
|
|
2080
2343
|
}
|
|
2081
2344
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
},
|
|
2087
|
-
duration: 0,
|
|
2088
|
-
velocity: 0
|
|
2345
|
+
let totalGraphNodes = -1;
|
|
2346
|
+
const defaultOptions$b = {
|
|
2347
|
+
toId: () => `${totalGraphNodes++}`,
|
|
2348
|
+
toChildren: (node) => node.children
|
|
2089
2349
|
};
|
|
2090
|
-
function
|
|
2091
|
-
const {
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
|
|
2104
|
-
const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
|
|
2105
|
-
metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
|
|
2106
|
-
const event2 = getSequence().at(-1);
|
|
2107
|
-
recognize?.(event2, api);
|
|
2108
|
-
if (getStatus() === "recognized")
|
|
2109
|
-
onRecognized(event2);
|
|
2110
|
-
storeDuration();
|
|
2350
|
+
function createGraph(options = {}) {
|
|
2351
|
+
const { toId, toChildren } = { ...defaultOptions$b, ...options };
|
|
2352
|
+
return function* (tree) {
|
|
2353
|
+
const root = tree[0], rootId = toId(root);
|
|
2354
|
+
function* toPair(node, id) {
|
|
2355
|
+
const children = toChildren(node) || [];
|
|
2356
|
+
for (const child of children) {
|
|
2357
|
+
const childId = toId(child);
|
|
2358
|
+
yield {
|
|
2359
|
+
node: childId,
|
|
2360
|
+
edge: { from: id, to: childId }
|
|
2361
|
+
};
|
|
2362
|
+
yield* toPair(child, childId);
|
|
2111
2363
|
}
|
|
2112
|
-
}
|
|
2113
|
-
|
|
2364
|
+
}
|
|
2365
|
+
yield { node: rootId };
|
|
2366
|
+
yield* toPair(root, rootId);
|
|
2114
2367
|
};
|
|
2115
|
-
storeDuration();
|
|
2116
2368
|
}
|
|
2117
2369
|
|
|
2118
|
-
function
|
|
2119
|
-
|
|
2370
|
+
function createSet$2(key, value, options = {}) {
|
|
2371
|
+
const { predicateKey = createEqual(key) } = options;
|
|
2372
|
+
return (associativeArray) => {
|
|
2373
|
+
const index = findIndex(
|
|
2374
|
+
([candidate]) => predicateKey(candidate)
|
|
2375
|
+
)(associativeArray);
|
|
2376
|
+
if (index === -1) {
|
|
2377
|
+
associativeArray.push([key, value]);
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
associativeArray[index][1] = value;
|
|
2381
|
+
return associativeArray;
|
|
2382
|
+
};
|
|
2120
2383
|
}
|
|
2121
|
-
function
|
|
2122
|
-
return
|
|
2384
|
+
function createClear$2() {
|
|
2385
|
+
return (associativeArray) => {
|
|
2386
|
+
associativeArray.length = 0;
|
|
2387
|
+
return associativeArray;
|
|
2388
|
+
};
|
|
2123
2389
|
}
|
|
2124
|
-
function
|
|
2125
|
-
|
|
2390
|
+
function createDelete$2(key, options = {}) {
|
|
2391
|
+
const { predicateKey = createEqual(key) } = options;
|
|
2392
|
+
return (associativeArray) => {
|
|
2393
|
+
const index = findIndex(
|
|
2394
|
+
([candidate]) => predicateKey(candidate)
|
|
2395
|
+
)(associativeArray);
|
|
2396
|
+
if (index === -1)
|
|
2397
|
+
return associativeArray;
|
|
2398
|
+
associativeArray.splice(index, 1);
|
|
2399
|
+
return associativeArray;
|
|
2400
|
+
};
|
|
2126
2401
|
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2402
|
+
|
|
2403
|
+
function createSet$1(key, value) {
|
|
2404
|
+
return (object) => {
|
|
2405
|
+
object[key] = value;
|
|
2406
|
+
return object;
|
|
2407
|
+
};
|
|
2129
2408
|
}
|
|
2130
|
-
function
|
|
2131
|
-
return
|
|
2409
|
+
function createDelete$1(key) {
|
|
2410
|
+
return (object) => {
|
|
2411
|
+
delete object[key];
|
|
2412
|
+
return object;
|
|
2413
|
+
};
|
|
2132
2414
|
}
|
|
2133
|
-
function
|
|
2134
|
-
return
|
|
2415
|
+
function createClear$1() {
|
|
2416
|
+
return (object) => {
|
|
2417
|
+
for (const key in object) {
|
|
2418
|
+
delete object[key];
|
|
2419
|
+
}
|
|
2420
|
+
return object;
|
|
2421
|
+
};
|
|
2135
2422
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2423
|
+
|
|
2424
|
+
function fromEventToKeyStatusCode({ code }) {
|
|
2425
|
+
const modifier = find(
|
|
2426
|
+
(modifier2) => code.includes(modifier2)
|
|
2427
|
+
)(modifiers);
|
|
2428
|
+
return modifier || code;
|
|
2429
|
+
}
|
|
2430
|
+
const modifiers = ["Alt", "Control", "Meta", "Shift"];
|
|
2431
|
+
|
|
2432
|
+
const createValue = createValue$2;
|
|
2433
|
+
function createSet(code, value) {
|
|
2434
|
+
return createSet$2(code, value);
|
|
2435
|
+
}
|
|
2436
|
+
const createClear = createClear$2;
|
|
2437
|
+
function createDelete(code) {
|
|
2438
|
+
return createDelete$2(code);
|
|
2439
|
+
}
|
|
2440
|
+
function createCode(query) {
|
|
2441
|
+
return function(candidate) {
|
|
2442
|
+
return query === candidate || includes(query)(modifiers) && candidate.includes(query) || includes(candidate)(modifiers) && query.includes(candidate);
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
const createValues = createValues$1;
|
|
2446
|
+
function predicateSomeKeyDown(statuses) {
|
|
2447
|
+
return includes("down")(createValues()(statuses));
|
|
2138
2448
|
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2449
|
+
|
|
2450
|
+
const defaultOptions$a = {
|
|
2451
|
+
toCode: (alias) => fromAliasToCode(alias)
|
|
2452
|
+
};
|
|
2453
|
+
const createKeycomboDown = (keycombo, options = {}) => {
|
|
2454
|
+
const { toLonghand, toCode } = { ...defaultOptions$a, ...options }, codes = pipe(
|
|
2455
|
+
createAliases({ toLonghand }),
|
|
2456
|
+
map(toCode)
|
|
2457
|
+
)(keycombo);
|
|
2458
|
+
return (statuses) => every(
|
|
2459
|
+
(code) => createValue(
|
|
2460
|
+
code,
|
|
2461
|
+
{ predicateKey: createCode(code) }
|
|
2462
|
+
)(statuses) === "down"
|
|
2463
|
+
)(codes);
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2466
|
+
function fromKeyboardEventDescriptorToAliases(event) {
|
|
2467
|
+
if (event.shiftKey && event.code in aliasesByShiftCode)
|
|
2468
|
+
return [aliasesByShiftCode[event.code]];
|
|
2469
|
+
const withoutModifierSide = toWithoutModifierSide(event.code);
|
|
2470
|
+
if (withoutModifierSide in aliasListsByModifier)
|
|
2471
|
+
return aliasListsByModifier[withoutModifierSide];
|
|
2472
|
+
return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
|
|
2141
2473
|
}
|
|
2474
|
+
const toWithoutModifierSide = createClip(/(?:Left|Right)$/);
|
|
2475
|
+
const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
|
|
2476
|
+
const aliasesByCode = {
|
|
2477
|
+
Backquote: "`",
|
|
2478
|
+
Minus: "-",
|
|
2479
|
+
Equal: "=",
|
|
2480
|
+
BracketLeft: "[",
|
|
2481
|
+
BracketRight: "]",
|
|
2482
|
+
Backslash: "\\",
|
|
2483
|
+
Semicolon: ";",
|
|
2484
|
+
Quote: "'",
|
|
2485
|
+
Comma: ",",
|
|
2486
|
+
Period: ".",
|
|
2487
|
+
Slash: "/",
|
|
2488
|
+
ArrowUp: "up",
|
|
2489
|
+
ArrowDown: "down",
|
|
2490
|
+
ArrowLeft: "left",
|
|
2491
|
+
ArrowRight: "right",
|
|
2492
|
+
Enter: "enter",
|
|
2493
|
+
Space: "space",
|
|
2494
|
+
Tab: "tab",
|
|
2495
|
+
Escape: "esc",
|
|
2496
|
+
Backspace: "backspace",
|
|
2497
|
+
Delete: "delete",
|
|
2498
|
+
Home: "home",
|
|
2499
|
+
End: "end",
|
|
2500
|
+
PageDown: "pagedown",
|
|
2501
|
+
PageUp: "pageup",
|
|
2502
|
+
CapsLock: "capslock",
|
|
2503
|
+
Camera: "camera"
|
|
2504
|
+
};
|
|
2505
|
+
const aliasesByShiftCode = {
|
|
2506
|
+
Backquote: "~",
|
|
2507
|
+
Minus: "_",
|
|
2508
|
+
Equal: "+",
|
|
2509
|
+
BracketLeft: "{",
|
|
2510
|
+
BracketRight: "}",
|
|
2511
|
+
Backslash: "|",
|
|
2512
|
+
Semicolon: ":",
|
|
2513
|
+
Quote: '"',
|
|
2514
|
+
Comma: "<",
|
|
2515
|
+
Period: ">",
|
|
2516
|
+
Slash: "?",
|
|
2517
|
+
Digit1: "!",
|
|
2518
|
+
Digit2: "@",
|
|
2519
|
+
Digit3: "#",
|
|
2520
|
+
Digit4: "$",
|
|
2521
|
+
Digit5: "%",
|
|
2522
|
+
Digit6: "^",
|
|
2523
|
+
Digit7: "&",
|
|
2524
|
+
Digit8: "*",
|
|
2525
|
+
Digit9: "(",
|
|
2526
|
+
Digit0: ")"
|
|
2527
|
+
};
|
|
2528
|
+
const aliasListsByModifier = {
|
|
2529
|
+
Alt: ["alt", "option", "opt"],
|
|
2530
|
+
Control: ["control", "ctrl"],
|
|
2531
|
+
Meta: ["meta", "command", "cmd"],
|
|
2532
|
+
Shift: ["shift"]
|
|
2533
|
+
};
|
|
2142
2534
|
|
|
2143
|
-
function
|
|
2144
|
-
return
|
|
2535
|
+
function fromCodeToAliases(code) {
|
|
2536
|
+
return fromKeyboardEventDescriptorToAliases({ code });
|
|
2145
2537
|
}
|
|
2146
2538
|
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
}
|
|
2188
|
-
return (event) => {
|
|
2189
|
-
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
|
|
2190
|
-
if (matchesOnly) {
|
|
2191
|
-
effect(event, {});
|
|
2192
|
-
return;
|
|
2539
|
+
const defaultOptions$9 = {
|
|
2540
|
+
toCode: (alias) => fromAliasToCode(alias),
|
|
2541
|
+
toAliases: (code) => fromCodeToAliases(code)
|
|
2542
|
+
};
|
|
2543
|
+
const createKeycomboMatch = (keycombo, options = {}) => {
|
|
2544
|
+
const { toLonghand, toCode, toAliases } = { ...defaultOptions$9, ...options }, aliases = createAliases({ toLonghand })(keycombo), codes = map(toCode)(aliases);
|
|
2545
|
+
return (statuses) => every(
|
|
2546
|
+
(code) => createValue(
|
|
2547
|
+
code,
|
|
2548
|
+
{ predicateKey: createCode(code) }
|
|
2549
|
+
)(statuses) === "down"
|
|
2550
|
+
)(codes) && every(
|
|
2551
|
+
([code, value]) => value === "up" || pipe(
|
|
2552
|
+
toAliases,
|
|
2553
|
+
some((alias) => includes(alias)(aliases))
|
|
2554
|
+
)(code)
|
|
2555
|
+
)(statuses);
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
function createKeyState({
|
|
2559
|
+
keycomboOrKeycombos,
|
|
2560
|
+
toLonghand,
|
|
2561
|
+
toCode,
|
|
2562
|
+
toAliases,
|
|
2563
|
+
getRequest
|
|
2564
|
+
}) {
|
|
2565
|
+
const fromComboToAliases = createAliases({ toLonghand }), narrowedKeycombos = createFilter(
|
|
2566
|
+
(keycombo) => !some(
|
|
2567
|
+
(alias) => includes(alias)(unsupportedAliases)
|
|
2568
|
+
)(fromComboToAliases(keycombo))
|
|
2569
|
+
)(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createKeycomboDownOptions = { toLonghand, toCode }, downPredicatesByKeycombo = (() => {
|
|
2570
|
+
const predicates = [];
|
|
2571
|
+
for (const keycombo of narrowedKeycombos) {
|
|
2572
|
+
predicates.push([
|
|
2573
|
+
keycombo,
|
|
2574
|
+
createKeycomboDown(
|
|
2575
|
+
keycombo,
|
|
2576
|
+
createKeycomboDownOptions
|
|
2577
|
+
)
|
|
2578
|
+
]);
|
|
2193
2579
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2580
|
+
return predicates;
|
|
2581
|
+
})(), createKeycomboMatchOptions = { ...createKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
|
|
2582
|
+
const predicates = {};
|
|
2583
|
+
for (const keycombo of narrowedKeycombos) {
|
|
2584
|
+
predicates[keycombo] = createKeycomboMatch(
|
|
2585
|
+
keycombo,
|
|
2586
|
+
createKeycomboMatchOptions
|
|
2587
|
+
);
|
|
2197
2588
|
}
|
|
2589
|
+
return predicates;
|
|
2590
|
+
})(), validAliases = pipe(
|
|
2591
|
+
flatMap(fromComboToAliases),
|
|
2592
|
+
unique(),
|
|
2593
|
+
toArray()
|
|
2594
|
+
)(narrowedKeycombos), getDownCombos = () => pipe(
|
|
2595
|
+
filter(([, predicate]) => predicate(statuses)),
|
|
2596
|
+
map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
|
|
2597
|
+
sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
|
|
2598
|
+
map(([keycombo]) => keycombo),
|
|
2599
|
+
toArray()
|
|
2600
|
+
)(downPredicatesByKeycombo), predicateValid = (event) => {
|
|
2601
|
+
const aliases = toAliases(event.code);
|
|
2602
|
+
return some(
|
|
2603
|
+
(validAlias) => includes(validAlias)(aliases)
|
|
2604
|
+
)(validAliases);
|
|
2605
|
+
}, cleanup = () => {
|
|
2606
|
+
window.cancelAnimationFrame(getRequest());
|
|
2607
|
+
}, statuses = [], toStatus = (...params) => createValue(...params)(statuses), setStatus = (...params) => createSet(...params)(statuses), clearStatuses = (...params) => createClear(...params)(statuses), deleteStatus = (...params) => createDelete(...params)(statuses);
|
|
2608
|
+
return {
|
|
2609
|
+
narrowedKeycombos,
|
|
2610
|
+
createKeycomboDownOptions,
|
|
2611
|
+
downPredicatesByKeycombo,
|
|
2612
|
+
createKeycomboMatchOptions,
|
|
2613
|
+
matchPredicatesByKeycombo,
|
|
2614
|
+
validAliases,
|
|
2615
|
+
getDownCombos,
|
|
2616
|
+
predicateValid,
|
|
2617
|
+
cleanup,
|
|
2618
|
+
statuses,
|
|
2619
|
+
toStatus,
|
|
2620
|
+
setStatus,
|
|
2621
|
+
clearStatuses,
|
|
2622
|
+
deleteStatus
|
|
2198
2623
|
};
|
|
2199
2624
|
}
|
|
2625
|
+
const unsupportedAliases = ["meta", "command", "cmd"];
|
|
2626
|
+
const unsupportedKeys = ["Meta"];
|
|
2200
2627
|
|
|
2201
|
-
function
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
}
|
|
2628
|
+
function createAliasesLength(options) {
|
|
2629
|
+
return pipe(
|
|
2630
|
+
createAliases(options),
|
|
2631
|
+
toLength()
|
|
2632
|
+
);
|
|
2207
2633
|
}
|
|
2208
2634
|
|
|
2209
|
-
function
|
|
2210
|
-
return
|
|
2211
|
-
}
|
|
2212
|
-
function predicateUndefined(value) {
|
|
2213
|
-
return value === void 0;
|
|
2214
|
-
}
|
|
2215
|
-
function predicateFunction(value) {
|
|
2216
|
-
return typeof value === "function";
|
|
2635
|
+
function toDirection(angle, unit = "degrees") {
|
|
2636
|
+
return Object.keys(directions).find((direction) => directions[direction][unit](angle));
|
|
2217
2637
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2638
|
+
const directions = {
|
|
2639
|
+
up: {
|
|
2640
|
+
degrees: (degrees) => degrees >= 67.5 && degrees <= 112.5,
|
|
2641
|
+
radians: (radians) => radians >= 0.375 * Math.PI && radians <= 0.625 * Math.PI
|
|
2642
|
+
},
|
|
2643
|
+
upRight: {
|
|
2644
|
+
degrees: (degrees) => degrees >= 22.5 && degrees < 67.5,
|
|
2645
|
+
radians: (radians) => radians >= 0.125 * Math.PI && radians < 0.375 * Math.PI
|
|
2646
|
+
},
|
|
2647
|
+
right: {
|
|
2648
|
+
degrees: (degrees) => degrees > 337.5 && degrees <= 360 || degrees < 22.5 && degrees >= 0,
|
|
2649
|
+
radians: (radians) => radians > 1.875 * Math.PI && radians <= 2 * Math.PI || radians < 0.125 * Math.PI && radians >= 0
|
|
2650
|
+
},
|
|
2651
|
+
downRight: {
|
|
2652
|
+
degrees: (degrees) => degrees > 292.5 && degrees <= 337.5,
|
|
2653
|
+
radians: (radians) => radians > 1.625 * Math.PI && radians <= 1.875 * Math.PI
|
|
2654
|
+
},
|
|
2655
|
+
down: {
|
|
2656
|
+
degrees: (degrees) => degrees >= 247.5 && degrees <= 292.5,
|
|
2657
|
+
radians: (radians) => radians >= 1.375 * Math.PI && radians <= 1.625 * Math.PI
|
|
2658
|
+
},
|
|
2659
|
+
downLeft: {
|
|
2660
|
+
degrees: (degrees) => degrees >= 202.5 && degrees < 247.5,
|
|
2661
|
+
radians: (radians) => radians >= 1.125 * Math.PI && radians < 1.375 * Math.PI
|
|
2662
|
+
},
|
|
2663
|
+
left: {
|
|
2664
|
+
degrees: (degrees) => degrees > 157.5 && degrees < 202.5,
|
|
2665
|
+
radians: (radians) => radians > 0.875 * Math.PI && radians < 1.125 * Math.PI
|
|
2666
|
+
},
|
|
2667
|
+
upLeft: {
|
|
2668
|
+
degrees: (degrees) => degrees > 112.5 && degrees <= 157.5,
|
|
2669
|
+
radians: (radians) => radians > 0.625 * Math.PI && radians <= 0.875 * Math.PI
|
|
2670
|
+
}
|
|
2671
|
+
};
|
|
2672
|
+
|
|
2673
|
+
function toHookApi({
|
|
2674
|
+
getSequence,
|
|
2675
|
+
getStatus,
|
|
2676
|
+
getMetadata
|
|
2677
|
+
}) {
|
|
2678
|
+
return {
|
|
2679
|
+
sequence: getSequence(),
|
|
2680
|
+
status: getStatus(),
|
|
2681
|
+
metadata: getMetadata()
|
|
2682
|
+
};
|
|
2220
2683
|
}
|
|
2221
|
-
|
|
2222
|
-
|
|
2684
|
+
|
|
2685
|
+
function toMousePoint(event) {
|
|
2686
|
+
return {
|
|
2687
|
+
x: event.clientX,
|
|
2688
|
+
y: event.clientY
|
|
2689
|
+
};
|
|
2223
2690
|
}
|
|
2224
|
-
function
|
|
2225
|
-
return
|
|
2691
|
+
function toTouchMovePoint(event) {
|
|
2692
|
+
return {
|
|
2693
|
+
x: event.touches.item(0).clientX,
|
|
2694
|
+
y: event.touches.item(0).clientY
|
|
2695
|
+
};
|
|
2226
2696
|
}
|
|
2227
|
-
function
|
|
2228
|
-
return
|
|
2697
|
+
function toTouchEndPoint(event) {
|
|
2698
|
+
return {
|
|
2699
|
+
x: event.changedTouches.item(0).clientX,
|
|
2700
|
+
y: event.changedTouches.item(0).clientY
|
|
2701
|
+
};
|
|
2229
2702
|
}
|
|
2230
2703
|
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
maxSequenceLength: true,
|
|
2238
|
-
effects: {}
|
|
2239
|
-
};
|
|
2240
|
-
this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
|
|
2241
|
-
this.effects = options?.effects || defaultOptions.effects;
|
|
2242
|
-
this.resetComputedMetadata();
|
|
2243
|
-
this.setSequence(sequence);
|
|
2244
|
-
this.effectApi = {
|
|
2245
|
-
getStatus: () => this.status,
|
|
2246
|
-
getMetadata: () => this.metadata,
|
|
2247
|
-
setMetadata: (metadata) => this.computedMetadata = metadata,
|
|
2248
|
-
recognized: () => this.recognized(),
|
|
2249
|
-
denied: () => this.denied(),
|
|
2250
|
-
ready: () => this.ready()
|
|
2251
|
-
};
|
|
2252
|
-
this.ready();
|
|
2253
|
-
}
|
|
2254
|
-
computedMetadata;
|
|
2255
|
-
resetComputedMetadata() {
|
|
2256
|
-
this.computedMetadata = {};
|
|
2257
|
-
}
|
|
2258
|
-
recognized() {
|
|
2259
|
-
this.computedStatus = "recognized";
|
|
2260
|
-
}
|
|
2261
|
-
denied() {
|
|
2262
|
-
this.computedStatus = "denied";
|
|
2263
|
-
}
|
|
2264
|
-
computedStatus;
|
|
2265
|
-
ready() {
|
|
2266
|
-
this.computedStatus = "ready";
|
|
2267
|
-
}
|
|
2268
|
-
get sequence() {
|
|
2269
|
-
return this.computedSequence;
|
|
2270
|
-
}
|
|
2271
|
-
set sequence(sequence) {
|
|
2272
|
-
this.setSequence(sequence);
|
|
2273
|
-
}
|
|
2274
|
-
get status() {
|
|
2275
|
-
return this.computedStatus;
|
|
2276
|
-
}
|
|
2277
|
-
get metadata() {
|
|
2278
|
-
return this.computedMetadata;
|
|
2279
|
-
}
|
|
2280
|
-
computedSequence;
|
|
2281
|
-
setSequence(sequence) {
|
|
2282
|
-
this.computedSequence = sequence;
|
|
2283
|
-
return this;
|
|
2284
|
-
}
|
|
2285
|
-
recognize(sequenceItem, { onRecognized } = {}) {
|
|
2286
|
-
this.recognizing();
|
|
2287
|
-
const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
|
|
2288
|
-
newSequence.push(sequenceItem2);
|
|
2289
|
-
if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
|
|
2290
|
-
newSequence.shift();
|
|
2291
|
-
}
|
|
2292
|
-
}, newSequence = [];
|
|
2293
|
-
for (const sequenceItem2 of this.sequence) {
|
|
2294
|
-
pushSequence(sequenceItem2);
|
|
2295
|
-
}
|
|
2296
|
-
pushSequence(sequenceItem);
|
|
2297
|
-
this.effectApi.getSequence = () => newSequence;
|
|
2298
|
-
this.effectApi.pushSequence = pushSequence;
|
|
2299
|
-
this.effectApi.onRecognized = onRecognized || (() => {
|
|
2300
|
-
});
|
|
2301
|
-
this.effects[type]?.(sequenceItem, { ...this.effectApi });
|
|
2302
|
-
switch (this.status) {
|
|
2303
|
-
case "ready":
|
|
2304
|
-
case "denied":
|
|
2305
|
-
this.resetComputedMetadata();
|
|
2306
|
-
this.setSequence([]);
|
|
2307
|
-
break;
|
|
2308
|
-
case "recognizing":
|
|
2309
|
-
case "recognized":
|
|
2310
|
-
this.setSequence(newSequence);
|
|
2311
|
-
break;
|
|
2312
|
-
}
|
|
2313
|
-
return this;
|
|
2314
|
-
}
|
|
2315
|
-
recognizing() {
|
|
2316
|
-
this.computedStatus = "recognizing";
|
|
2317
|
-
}
|
|
2318
|
-
toType(sequenceItem) {
|
|
2319
|
-
if (predicateArray(sequenceItem)) {
|
|
2320
|
-
if (sequenceItem[0] instanceof IntersectionObserverEntry) {
|
|
2321
|
-
return "intersect";
|
|
2322
|
-
}
|
|
2323
|
-
if (sequenceItem[0] instanceof MutationRecord) {
|
|
2324
|
-
return "mutate";
|
|
2325
|
-
}
|
|
2326
|
-
if (sequenceItem[0] instanceof ResizeObserverEntry) {
|
|
2327
|
-
return "resize";
|
|
2328
|
-
}
|
|
2329
|
-
} else {
|
|
2330
|
-
if (sequenceItem instanceof MediaQueryListEvent) {
|
|
2331
|
-
return sequenceItem.media;
|
|
2332
|
-
}
|
|
2333
|
-
if ("didTimeout" in sequenceItem) {
|
|
2334
|
-
return "idle";
|
|
2335
|
-
}
|
|
2336
|
-
return sequenceItem.type;
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2704
|
+
function toPolarCoordinates({ xA, xB, yA, yB }) {
|
|
2705
|
+
const distance = Math.hypot(xB - xA, yB - yA), angle = Math.atan2(yA - yB, xB - xA), radians = angle >= 0 ? angle : 2 * Math.PI + angle, degrees = radians * 180 / Math.PI;
|
|
2706
|
+
return {
|
|
2707
|
+
distance,
|
|
2708
|
+
angle: { radians, degrees }
|
|
2709
|
+
};
|
|
2339
2710
|
}
|
|
2340
2711
|
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2712
|
+
const initialMetadata$3 = {
|
|
2713
|
+
times: {
|
|
2714
|
+
start: 0,
|
|
2715
|
+
end: 0
|
|
2716
|
+
},
|
|
2717
|
+
duration: 0
|
|
2718
|
+
};
|
|
2719
|
+
function storeKeyboardTimeMetadata({
|
|
2720
|
+
event,
|
|
2721
|
+
api,
|
|
2722
|
+
getTimeMetadata,
|
|
2723
|
+
getShouldStore,
|
|
2724
|
+
setRequest,
|
|
2725
|
+
recognize
|
|
2726
|
+
}) {
|
|
2727
|
+
if (!getShouldStore())
|
|
2728
|
+
return;
|
|
2729
|
+
const { getStatus, listenInjection: { effect } } = api, timeMetadata = getTimeMetadata();
|
|
2730
|
+
if (!timeMetadata.times)
|
|
2731
|
+
timeMetadata.times = createClone()(initialMetadata$3.times);
|
|
2732
|
+
timeMetadata.times.start = Math.round(event.timeStamp);
|
|
2733
|
+
timeMetadata.times.end = Math.round(event.timeStamp);
|
|
2734
|
+
const storeDuration = () => {
|
|
2735
|
+
const request = requestAnimationFrame((timestamp) => {
|
|
2736
|
+
if (!getShouldStore())
|
|
2737
|
+
return;
|
|
2738
|
+
timeMetadata.times.end = Math.round(timestamp);
|
|
2739
|
+
timeMetadata.duration = Math.max(0, timeMetadata.times.end - timeMetadata.times.start);
|
|
2740
|
+
if (recognize) {
|
|
2741
|
+
recognize(event, api);
|
|
2742
|
+
if (getStatus() === "recognized")
|
|
2743
|
+
effect(event);
|
|
2744
|
+
}
|
|
2745
|
+
storeDuration();
|
|
2746
|
+
});
|
|
2747
|
+
setRequest(request);
|
|
2748
|
+
};
|
|
2749
|
+
storeDuration();
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
const initialMetadata$2 = {
|
|
2753
|
+
points: {
|
|
2754
|
+
start: { x: 0, y: 0 },
|
|
2755
|
+
end: { x: 0, y: 0 }
|
|
2380
2756
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
case "documentevent":
|
|
2405
|
-
this.documentEventListen(effect, options);
|
|
2406
|
-
break;
|
|
2407
|
-
case "event":
|
|
2408
|
-
this.eventListen(effect, options);
|
|
2409
|
-
break;
|
|
2757
|
+
};
|
|
2758
|
+
function storePointerStartMetadata(event, api) {
|
|
2759
|
+
const { getMetadata } = api, metadata = getMetadata();
|
|
2760
|
+
const point = event instanceof MouseEvent ? toMousePoint(event) : toTouchMovePoint(event);
|
|
2761
|
+
if (!metadata.points)
|
|
2762
|
+
metadata.points = createClone()(initialMetadata$2.points);
|
|
2763
|
+
metadata.points.start = point;
|
|
2764
|
+
metadata.points.end = point;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
const initialMetadata$1 = {
|
|
2768
|
+
distance: {
|
|
2769
|
+
straight: {
|
|
2770
|
+
fromStart: 0,
|
|
2771
|
+
fromPrevious: 0
|
|
2772
|
+
},
|
|
2773
|
+
horizontal: {
|
|
2774
|
+
fromStart: 0,
|
|
2775
|
+
fromPrevious: 0
|
|
2776
|
+
},
|
|
2777
|
+
vertical: {
|
|
2778
|
+
fromStart: 0,
|
|
2779
|
+
fromPrevious: 0
|
|
2410
2780
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
mutationListen(effect, options) {
|
|
2420
|
-
const { target = document.querySelector("html"), observe } = options, id = new MutationObserver(effect);
|
|
2421
|
-
id.observe(target, observe);
|
|
2422
|
-
this.active.add({ target, id });
|
|
2781
|
+
},
|
|
2782
|
+
angle: {
|
|
2783
|
+
fromPrevious: { radians: 0, degrees: 0 },
|
|
2784
|
+
fromStart: { radians: 0, degrees: 0 }
|
|
2785
|
+
},
|
|
2786
|
+
direction: {
|
|
2787
|
+
fromPrevious: "up",
|
|
2788
|
+
fromStart: "up"
|
|
2423
2789
|
}
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2790
|
+
};
|
|
2791
|
+
function storePointerMoveMetadata(event, api) {
|
|
2792
|
+
const { getMetadata } = api, metadata = getMetadata();
|
|
2793
|
+
if (!metadata.distance) {
|
|
2794
|
+
metadata.distance = createClone()(initialMetadata$1.distance);
|
|
2795
|
+
metadata.angle = createClone()(initialMetadata$1.angle);
|
|
2796
|
+
metadata.direction = createClone()(initialMetadata$1.direction);
|
|
2428
2797
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
options.instantEffect(target);
|
|
2798
|
+
const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
|
|
2799
|
+
if (event instanceof MouseEvent) {
|
|
2800
|
+
return toMousePoint(event);
|
|
2433
2801
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
|
|
2440
|
-
this.active.add({ target: window, id });
|
|
2441
|
-
}
|
|
2442
|
-
messageListen(effect, options) {
|
|
2443
|
-
const { target = new BroadcastChannel("baleada") } = options;
|
|
2444
|
-
target.addEventListener(this.type, (event) => effect(event));
|
|
2445
|
-
this.active.add({ target, id: [this.type, effect] });
|
|
2446
|
-
}
|
|
2447
|
-
recognizeableListen(effect, options) {
|
|
2448
|
-
const guardedEffect = (sequenceItem) => {
|
|
2449
|
-
this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
|
|
2450
|
-
if (this.recognizeable.status === "recognized")
|
|
2451
|
-
effect(sequenceItem);
|
|
2452
|
-
};
|
|
2453
|
-
for (const type of this.recognizeableEffectsKeys) {
|
|
2454
|
-
const listenable = new Listenable(type);
|
|
2455
|
-
listenable.listen(guardedEffect, options);
|
|
2456
|
-
this.active.add({ id: listenable });
|
|
2802
|
+
if (event instanceof TouchEvent) {
|
|
2803
|
+
if (event.type === "touchmove") {
|
|
2804
|
+
return toTouchMovePoint(event);
|
|
2805
|
+
}
|
|
2806
|
+
return toTouchEndPoint(event);
|
|
2457
2807
|
}
|
|
2808
|
+
})(), { distance: distanceFromPrevious, angle: angleFromPrevious } = toPolarCoordinates({
|
|
2809
|
+
xA: previousX,
|
|
2810
|
+
xB: newX,
|
|
2811
|
+
yA: previousY,
|
|
2812
|
+
yB: newY
|
|
2813
|
+
}), { distance: distanceFromStart, angle: angleFromStart } = toPolarCoordinates({
|
|
2814
|
+
xA: startX,
|
|
2815
|
+
xB: newX,
|
|
2816
|
+
yA: startY,
|
|
2817
|
+
yB: newY
|
|
2818
|
+
});
|
|
2819
|
+
metadata.distance.straight.fromPrevious = distanceFromPrevious;
|
|
2820
|
+
metadata.distance.horizontal.fromPrevious = newX - previousX;
|
|
2821
|
+
metadata.distance.vertical.fromPrevious = newY - previousY;
|
|
2822
|
+
metadata.angle.fromPrevious = angleFromPrevious;
|
|
2823
|
+
metadata.direction.fromPrevious = toDirection(angleFromPrevious.degrees);
|
|
2824
|
+
metadata.distance.straight.fromStart = distanceFromStart;
|
|
2825
|
+
metadata.distance.horizontal.fromStart = newX - startX;
|
|
2826
|
+
metadata.distance.vertical.fromStart = newY - startY;
|
|
2827
|
+
metadata.angle.fromStart = angleFromStart;
|
|
2828
|
+
metadata.direction.fromStart = toDirection(angleFromStart.degrees);
|
|
2829
|
+
metadata.points.end = { x: newX, y: newY };
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
const initialMetadata = {
|
|
2833
|
+
times: {
|
|
2834
|
+
start: 0,
|
|
2835
|
+
end: 0
|
|
2836
|
+
},
|
|
2837
|
+
duration: 0,
|
|
2838
|
+
velocity: 0
|
|
2839
|
+
};
|
|
2840
|
+
function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recognize) {
|
|
2841
|
+
const { getSequence, getMetadata, getStatus, listenInjection: { effect } } = api, metadata = getMetadata();
|
|
2842
|
+
if (!metadata.times) {
|
|
2843
|
+
metadata.times = createClone()(initialMetadata.times);
|
|
2458
2844
|
}
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2845
|
+
metadata.times.start = Math.round(event.timeStamp);
|
|
2846
|
+
metadata.times.end = Math.round(event.timeStamp);
|
|
2847
|
+
let previousTime = metadata.times.start;
|
|
2848
|
+
const storeDuration = () => {
|
|
2849
|
+
const request = requestAnimationFrame((timestamp) => {
|
|
2850
|
+
if (getShouldStore()) {
|
|
2851
|
+
previousTime = metadata.times.end;
|
|
2852
|
+
metadata.times.end = Math.round(timestamp);
|
|
2853
|
+
metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
|
|
2854
|
+
const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
|
|
2855
|
+
metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
|
|
2856
|
+
const event2 = getSequence().at(-1);
|
|
2857
|
+
recognize?.(event2, api);
|
|
2858
|
+
if (getStatus() === "recognized")
|
|
2859
|
+
effect(event2);
|
|
2860
|
+
storeDuration();
|
|
2861
|
+
}
|
|
2862
|
+
});
|
|
2863
|
+
setRequest(request);
|
|
2864
|
+
};
|
|
2865
|
+
storeDuration();
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
function defineGraph(nodes, edges) {
|
|
2869
|
+
return { nodes, edges };
|
|
2870
|
+
}
|
|
2871
|
+
function defineGraphNodes(nodes) {
|
|
2872
|
+
return nodes;
|
|
2873
|
+
}
|
|
2874
|
+
function defineGraphEdges(edges) {
|
|
2875
|
+
return edges;
|
|
2876
|
+
}
|
|
2877
|
+
function defineGraphNode(node) {
|
|
2878
|
+
return node;
|
|
2879
|
+
}
|
|
2880
|
+
function defineGraphEdge(from, to, predicateShouldTraverse) {
|
|
2881
|
+
return { from, to, predicateShouldTraverse };
|
|
2882
|
+
}
|
|
2883
|
+
function defineGraphAsync(nodes, edges) {
|
|
2884
|
+
return { nodes, edges };
|
|
2885
|
+
}
|
|
2886
|
+
function defineGraphAsyncEdges(edges) {
|
|
2887
|
+
return edges;
|
|
2888
|
+
}
|
|
2889
|
+
function defineGraphAsyncEdge(from, to, predicateShouldTraverse) {
|
|
2890
|
+
return { from, to, predicateShouldTraverse };
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
function defineAssociativeArray(associativeArray) {
|
|
2894
|
+
return associativeArray;
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
function createExceptAndOnlyEffect(type, effect, options) {
|
|
2898
|
+
const { except = [], only = [] } = options;
|
|
2899
|
+
if (type === "keydown" || type === "keyup") {
|
|
2900
|
+
return (event) => {
|
|
2901
|
+
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
|
|
2902
|
+
if (matchesOnly) {
|
|
2903
|
+
effect(event);
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
if (only.length === 0 && !matchesExcept) {
|
|
2907
|
+
effect(event);
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2463
2910
|
};
|
|
2464
|
-
this.eventListen(effect, narrowedOptions);
|
|
2465
|
-
}
|
|
2466
|
-
eventListen(effect, options) {
|
|
2467
|
-
const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
|
|
2468
|
-
this.addEventListeners(eventListeners, options);
|
|
2469
|
-
}
|
|
2470
|
-
addEventListeners(eventListeners, options) {
|
|
2471
|
-
const { target = document } = options;
|
|
2472
|
-
for (const eventListener of eventListeners) {
|
|
2473
|
-
target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
|
|
2474
|
-
this.active.add({ target, id: eventListener });
|
|
2475
|
-
}
|
|
2476
2911
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
stop(stoppable);
|
|
2490
|
-
this.active.delete(stoppable);
|
|
2491
|
-
}
|
|
2492
|
-
if (shouldUpdateStatus) {
|
|
2493
|
-
this.stopped();
|
|
2494
|
-
}
|
|
2495
|
-
break;
|
|
2496
|
-
}
|
|
2497
|
-
return this;
|
|
2912
|
+
if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
|
|
2913
|
+
return (event) => {
|
|
2914
|
+
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
|
|
2915
|
+
if (matchesOnly) {
|
|
2916
|
+
effect(event);
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2919
|
+
if (only.length === 0 && !matchesExcept) {
|
|
2920
|
+
effect(event);
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2498
2924
|
}
|
|
2499
|
-
|
|
2500
|
-
|
|
2925
|
+
if (type.startsWith("pointer")) {
|
|
2926
|
+
return (event) => {
|
|
2927
|
+
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
|
|
2928
|
+
if (matchesOnly) {
|
|
2929
|
+
effect(event);
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2932
|
+
if (only.length === 0 && !matchesExcept) {
|
|
2933
|
+
effect(event);
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
};
|
|
2501
2937
|
}
|
|
2938
|
+
return (event) => {
|
|
2939
|
+
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
|
|
2940
|
+
if (matchesOnly) {
|
|
2941
|
+
effect(event, {});
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2944
|
+
if (only.length === 0 && !matchesExcept) {
|
|
2945
|
+
effect(event, {});
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2502
2949
|
}
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
return;
|
|
2950
|
+
|
|
2951
|
+
function getDomAvailability() {
|
|
2952
|
+
try {
|
|
2953
|
+
return !!window ? "available" : "unavailable";
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
return "unavailable";
|
|
2507
2956
|
}
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
function predicateArray(value) {
|
|
2960
|
+
return Array.isArray(value);
|
|
2961
|
+
}
|
|
2962
|
+
function predicateUndefined(value) {
|
|
2963
|
+
return value === void 0;
|
|
2964
|
+
}
|
|
2965
|
+
function predicateFunction(value) {
|
|
2966
|
+
return typeof value === "function";
|
|
2967
|
+
}
|
|
2968
|
+
function predicateNull(value) {
|
|
2969
|
+
return value === null;
|
|
2970
|
+
}
|
|
2971
|
+
function predicateNumber(value) {
|
|
2972
|
+
return typeof value === "number";
|
|
2973
|
+
}
|
|
2974
|
+
function predicateString(value) {
|
|
2975
|
+
return typeof value === "string";
|
|
2976
|
+
}
|
|
2977
|
+
function predicateObject(value) {
|
|
2978
|
+
return typeof value === "object";
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
function toInterpolated({ previous, next, progress }, options = {}) {
|
|
2982
|
+
if (predicateUndefined(previous)) {
|
|
2983
|
+
return next;
|
|
2512
2984
|
}
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
2515
|
-
target2.removeEventListener(id2[0], id2[1]);
|
|
2516
|
-
return;
|
|
2985
|
+
if (predicateNumber(previous) && predicateNumber(next)) {
|
|
2986
|
+
return (next - previous) * progress + previous;
|
|
2517
2987
|
}
|
|
2518
|
-
if (
|
|
2519
|
-
const {
|
|
2520
|
-
|
|
2521
|
-
return;
|
|
2988
|
+
if (predicateString(previous) && predicateString(next)) {
|
|
2989
|
+
const { color: createMixOptions } = options;
|
|
2990
|
+
return createMix(`${next} ${progress * 100}%`, createMixOptions)(previous);
|
|
2522
2991
|
}
|
|
2523
|
-
if (
|
|
2524
|
-
const
|
|
2525
|
-
|
|
2526
|
-
return;
|
|
2992
|
+
if (predicateArray(previous) && predicateArray(next)) {
|
|
2993
|
+
const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
|
|
2994
|
+
return createSlice(0, sliceEnd)(sliceTarget);
|
|
2527
2995
|
}
|
|
2528
|
-
const { target, id } = stoppable;
|
|
2529
|
-
target.removeEventListener(id[0], id[1], id[2]);
|
|
2530
|
-
}
|
|
2531
|
-
function toImplementation(type) {
|
|
2532
|
-
return find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
|
|
2533
|
-
}
|
|
2534
|
-
const predicatesByImplementation = /* @__PURE__ */ new Map([
|
|
2535
|
-
[
|
|
2536
|
-
"recognizeable",
|
|
2537
|
-
(type) => type === "recognizeable"
|
|
2538
|
-
],
|
|
2539
|
-
[
|
|
2540
|
-
"intersection",
|
|
2541
|
-
(type) => type === "intersect"
|
|
2542
|
-
],
|
|
2543
|
-
[
|
|
2544
|
-
"mutation",
|
|
2545
|
-
(type) => type === "mutate"
|
|
2546
|
-
],
|
|
2547
|
-
[
|
|
2548
|
-
"resize",
|
|
2549
|
-
(type) => type === "resize"
|
|
2550
|
-
],
|
|
2551
|
-
[
|
|
2552
|
-
"mediaquery",
|
|
2553
|
-
(type) => implementationREs.mediaquery.test(type)
|
|
2554
|
-
],
|
|
2555
|
-
[
|
|
2556
|
-
"idle",
|
|
2557
|
-
(type) => type === "idle"
|
|
2558
|
-
],
|
|
2559
|
-
[
|
|
2560
|
-
"message",
|
|
2561
|
-
(type) => type === "message" || type === "messageerror"
|
|
2562
|
-
],
|
|
2563
|
-
[
|
|
2564
|
-
"documentevent",
|
|
2565
|
-
(type) => documentEvents.has(type)
|
|
2566
|
-
],
|
|
2567
|
-
[
|
|
2568
|
-
"event",
|
|
2569
|
-
() => true
|
|
2570
|
-
]
|
|
2571
|
-
]);
|
|
2572
|
-
const documentEvents = /* @__PURE__ */ new Set([
|
|
2573
|
-
"fullscreenchange",
|
|
2574
|
-
"fullscreenerror",
|
|
2575
|
-
"pointerlockchange",
|
|
2576
|
-
"pointerlockerror",
|
|
2577
|
-
"readystatechange",
|
|
2578
|
-
"visibilitychange"
|
|
2579
|
-
]);
|
|
2580
|
-
const implementationREs = {
|
|
2581
|
-
mediaquery: /^\(.+\)$/
|
|
2582
|
-
};
|
|
2583
|
-
function toAddEventListenerParams(type, effect, options) {
|
|
2584
|
-
const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
|
|
2585
|
-
return { exceptAndOnlyEffect, effectOptions };
|
|
2586
2996
|
}
|
|
2587
|
-
const observerAssertionsByType = {
|
|
2588
|
-
intersect: (observer) => observer instanceof IntersectionObserver,
|
|
2589
|
-
mutate: (observer) => observer instanceof MutationObserver,
|
|
2590
|
-
resize: (observer) => observer instanceof ResizeObserver
|
|
2591
|
-
};
|
|
2592
2997
|
|
|
2593
2998
|
const defaultOptions$8 = {
|
|
2594
2999
|
duration: 0,
|
|
@@ -2603,6 +3008,14 @@ const defaultOptions$8 = {
|
|
|
2603
3008
|
iterations: 1,
|
|
2604
3009
|
alternates: false
|
|
2605
3010
|
};
|
|
3011
|
+
const defaultAnimateOptions = {
|
|
3012
|
+
interpolate: {
|
|
3013
|
+
color: {
|
|
3014
|
+
method: "oklch",
|
|
3015
|
+
...defaultCreateMixOptions
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
};
|
|
2606
3019
|
class Animateable {
|
|
2607
3020
|
initialDuration;
|
|
2608
3021
|
iterationLimit;
|
|
@@ -2625,8 +3038,8 @@ class Animateable {
|
|
|
2625
3038
|
this.iterationLimit = options?.iterations || defaultOptions$8.iterations;
|
|
2626
3039
|
this.alternates = options?.alternates || defaultOptions$8.alternates;
|
|
2627
3040
|
this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
|
|
2628
|
-
this.toAnimationProgress =
|
|
2629
|
-
this.reversedToAnimationProgress =
|
|
3041
|
+
this.toAnimationProgress = createAnimationProgress(this.controlPoints);
|
|
3042
|
+
this.reversedToAnimationProgress = createAnimationProgress(this.reversedControlPoints);
|
|
2630
3043
|
this.playCache = {};
|
|
2631
3044
|
this.reverseCache = {};
|
|
2632
3045
|
this.pauseCache = {};
|
|
@@ -2876,7 +3289,7 @@ class Animateable {
|
|
|
2876
3289
|
computedRequest;
|
|
2877
3290
|
createAnimate(type) {
|
|
2878
3291
|
return (effect, options = {}) => {
|
|
2879
|
-
const { interpolate: interpolateOptions } = options;
|
|
3292
|
+
const { interpolate: interpolateOptions } = createDeepMerge(options)(defaultAnimateOptions);
|
|
2880
3293
|
this.computedRequest = window.requestAnimationFrame((timestamp) => {
|
|
2881
3294
|
this.setStartTimeAndStatus(type, timestamp);
|
|
2882
3295
|
const timeElapsed = Math.min(timestamp - this.startTime - this.totalTimeInvisible, this.duration), timeRemaining = this.duration - timeElapsed, timeProgress = timeElapsed / this.duration, toAnimationProgress = this.getToAnimationProgress(type), animationProgress = toAnimationProgress(timeProgress);
|
|
@@ -3247,7 +3660,7 @@ function createGetEaseables(fromKeyframeToControlPoints) {
|
|
|
3247
3660
|
(easeables, property) => {
|
|
3248
3661
|
const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
|
|
3249
3662
|
(propertyEaseables2, keyframe, index) => {
|
|
3250
|
-
const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 :
|
|
3663
|
+
const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 : createAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
|
|
3251
3664
|
propertyEaseables2.push({
|
|
3252
3665
|
property,
|
|
3253
3666
|
value: { previous, next },
|
|
@@ -3300,32 +3713,10 @@ function fromControlPointsToReversedControlPoints(points) {
|
|
|
3300
3713
|
{ x: 1 - points[0].x, y: 1 - points[0].y }
|
|
3301
3714
|
];
|
|
3302
3715
|
}
|
|
3303
|
-
function
|
|
3716
|
+
function createAnimationProgress(points) {
|
|
3304
3717
|
const { 0: { x: point1x, y: point1y }, 1: { x: point2x, y: point2y } } = points;
|
|
3305
3718
|
return BezierEasing(point1x, point1y, point2x, point2y);
|
|
3306
3719
|
}
|
|
3307
|
-
function toInterpolated({ previous, next, progress }, options = {}) {
|
|
3308
|
-
if (predicateUndefined(previous)) {
|
|
3309
|
-
return next;
|
|
3310
|
-
}
|
|
3311
|
-
if (predicateNumber(previous) && predicateNumber(next)) {
|
|
3312
|
-
return (next - previous) * progress + previous;
|
|
3313
|
-
}
|
|
3314
|
-
if (predicateString(previous) && predicateString(next)) {
|
|
3315
|
-
return mix(
|
|
3316
|
-
options.colorModel,
|
|
3317
|
-
{
|
|
3318
|
-
start: previous,
|
|
3319
|
-
end: next,
|
|
3320
|
-
alpha: progress
|
|
3321
|
-
}
|
|
3322
|
-
).toRgb().toRgbString();
|
|
3323
|
-
}
|
|
3324
|
-
if (predicateArray(previous) && predicateArray(next)) {
|
|
3325
|
-
const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
|
|
3326
|
-
return createSlice(0, sliceEnd)(sliceTarget);
|
|
3327
|
-
}
|
|
3328
|
-
}
|
|
3329
3720
|
const linear = [
|
|
3330
3721
|
0,
|
|
3331
3722
|
0,
|
|
@@ -3724,7 +4115,6 @@ class Completeable {
|
|
|
3724
4115
|
}
|
|
3725
4116
|
return this;
|
|
3726
4117
|
}
|
|
3727
|
-
// TODO: Support array of selections for multi cursor editing
|
|
3728
4118
|
computedSelection;
|
|
3729
4119
|
setSelection(selection) {
|
|
3730
4120
|
this.computedSelection = selection;
|
|
@@ -4102,22 +4492,32 @@ class Drawable {
|
|
|
4102
4492
|
}
|
|
4103
4493
|
}
|
|
4104
4494
|
function toD(stroke) {
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4495
|
+
if (stroke.length < 4)
|
|
4496
|
+
return "";
|
|
4497
|
+
let a = stroke[0];
|
|
4498
|
+
let b = stroke[1];
|
|
4499
|
+
const c = stroke[2];
|
|
4500
|
+
let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${average()([b[0], c[0]]).toFixed(2)},${average()([b[1], c[1]]).toFixed(2)} T`;
|
|
4501
|
+
for (let i = 2; i < stroke.length - 1; i++) {
|
|
4502
|
+
a = stroke[i];
|
|
4503
|
+
b = stroke[i + 1];
|
|
4504
|
+
result += `${average()([a[0], b[0]]).toFixed(2)},${average()([a[1], b[1]]).toFixed(2)} `;
|
|
4505
|
+
}
|
|
4506
|
+
return `${result}Z`;
|
|
4109
4507
|
}
|
|
4110
4508
|
function toFlattenedD(stroke) {
|
|
4111
|
-
if (stroke.length === 0)
|
|
4509
|
+
if (stroke.length === 0)
|
|
4112
4510
|
return "";
|
|
4511
|
+
const faces = polygonClipping.union([stroke]);
|
|
4512
|
+
const flattenedD = [];
|
|
4513
|
+
for (const face of faces) {
|
|
4514
|
+
for (const ring of face) {
|
|
4515
|
+
flattenedD.push(toD(ring));
|
|
4516
|
+
}
|
|
4113
4517
|
}
|
|
4114
|
-
|
|
4115
|
-
return createReduce((dFromMultiPolygon, polygon) => {
|
|
4116
|
-
return dFromMultiPolygon + createReduce((dFromRing, points) => {
|
|
4117
|
-
return dFromRing + toD(points);
|
|
4118
|
-
}, "")(polygon);
|
|
4119
|
-
}, "")(multiPolygon);
|
|
4518
|
+
return toSpaceSeparated(flattenedD);
|
|
4120
4519
|
}
|
|
4520
|
+
const toSpaceSeparated = join(" ");
|
|
4121
4521
|
|
|
4122
4522
|
class Resolveable {
|
|
4123
4523
|
constructor(getPromise, options = {}) {
|
|
@@ -4140,20 +4540,23 @@ class Resolveable {
|
|
|
4140
4540
|
get value() {
|
|
4141
4541
|
return this.computedValue;
|
|
4142
4542
|
}
|
|
4543
|
+
get error() {
|
|
4544
|
+
return this.computedError;
|
|
4545
|
+
}
|
|
4143
4546
|
computedGetPromise;
|
|
4144
4547
|
setGetPromise(getPromise) {
|
|
4145
4548
|
this.computedGetPromise = getPromise;
|
|
4146
4549
|
return this;
|
|
4147
4550
|
}
|
|
4148
4551
|
computedValue;
|
|
4149
|
-
|
|
4552
|
+
computedError;
|
|
4553
|
+
async resolve() {
|
|
4150
4554
|
this.resolving();
|
|
4151
4555
|
try {
|
|
4152
|
-
|
|
4153
|
-
this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
|
|
4556
|
+
this.computedValue = await this.getPromise();
|
|
4154
4557
|
this.resolved();
|
|
4155
4558
|
} catch (error) {
|
|
4156
|
-
this.
|
|
4559
|
+
this.computedError = error;
|
|
4157
4560
|
this.errored();
|
|
4158
4561
|
}
|
|
4159
4562
|
return this;
|
|
@@ -4195,27 +4598,26 @@ class Fetchable {
|
|
|
4195
4598
|
set resource(resource) {
|
|
4196
4599
|
this.setResource(resource);
|
|
4197
4600
|
}
|
|
4601
|
+
get status() {
|
|
4602
|
+
return this.computedStatus;
|
|
4603
|
+
}
|
|
4198
4604
|
computedKy;
|
|
4199
4605
|
get ky() {
|
|
4200
4606
|
return this.computedKy;
|
|
4201
4607
|
}
|
|
4202
4608
|
computedAbortController;
|
|
4203
4609
|
get abortController() {
|
|
4204
|
-
if (!this.computedAbortController)
|
|
4610
|
+
if (!this.computedAbortController)
|
|
4205
4611
|
this.computedAbortController = new AbortController();
|
|
4206
|
-
}
|
|
4207
4612
|
return this.computedAbortController;
|
|
4208
4613
|
}
|
|
4209
|
-
get status() {
|
|
4210
|
-
return this.computedStatus;
|
|
4211
|
-
}
|
|
4212
|
-
get response() {
|
|
4213
|
-
return this.computedResponse;
|
|
4214
|
-
}
|
|
4215
4614
|
computedRetryCount = 0;
|
|
4216
4615
|
get retryCount() {
|
|
4217
4616
|
return this.computedRetryCount;
|
|
4218
4617
|
}
|
|
4618
|
+
get response() {
|
|
4619
|
+
return this.computedResponse;
|
|
4620
|
+
}
|
|
4219
4621
|
get error() {
|
|
4220
4622
|
return this.computedError;
|
|
4221
4623
|
}
|
|
@@ -4287,27 +4689,27 @@ class Fetchable {
|
|
|
4287
4689
|
this.computedStatus = "errored";
|
|
4288
4690
|
}
|
|
4289
4691
|
async get(options = {}) {
|
|
4290
|
-
await this.fetch({
|
|
4692
|
+
await this.fetch({ ...options, method: "get" });
|
|
4291
4693
|
return this;
|
|
4292
4694
|
}
|
|
4293
4695
|
async patch(options = {}) {
|
|
4294
|
-
await this.fetch({
|
|
4696
|
+
await this.fetch({ ...options, method: "patch" });
|
|
4295
4697
|
return this;
|
|
4296
4698
|
}
|
|
4297
4699
|
async post(options = {}) {
|
|
4298
|
-
await this.fetch({
|
|
4700
|
+
await this.fetch({ ...options, method: "post" });
|
|
4299
4701
|
return this;
|
|
4300
4702
|
}
|
|
4301
4703
|
async put(options = {}) {
|
|
4302
|
-
await this.fetch({
|
|
4704
|
+
await this.fetch({ ...options, method: "put" });
|
|
4303
4705
|
return this;
|
|
4304
4706
|
}
|
|
4305
4707
|
async delete(options = {}) {
|
|
4306
|
-
await this.fetch({
|
|
4708
|
+
await this.fetch({ ...options, method: "delete" });
|
|
4307
4709
|
return this;
|
|
4308
4710
|
}
|
|
4309
4711
|
async head(options = {}) {
|
|
4310
|
-
await this.fetch({
|
|
4712
|
+
await this.fetch({ ...options, method: "head" });
|
|
4311
4713
|
return this;
|
|
4312
4714
|
}
|
|
4313
4715
|
abort() {
|
|
@@ -4404,6 +4806,9 @@ class Grantable {
|
|
|
4404
4806
|
get permission() {
|
|
4405
4807
|
return this.computedPermission;
|
|
4406
4808
|
}
|
|
4809
|
+
get error() {
|
|
4810
|
+
return this.computedError;
|
|
4811
|
+
}
|
|
4407
4812
|
get status() {
|
|
4408
4813
|
return this.computedStatus;
|
|
4409
4814
|
}
|
|
@@ -4413,22 +4818,23 @@ class Grantable {
|
|
|
4413
4818
|
return this;
|
|
4414
4819
|
}
|
|
4415
4820
|
computedPermission;
|
|
4416
|
-
|
|
4417
|
-
|
|
4821
|
+
computedError;
|
|
4822
|
+
async grant() {
|
|
4823
|
+
this.granting();
|
|
4418
4824
|
try {
|
|
4419
4825
|
this.computedPermission = await navigator.permissions.query(this.descriptor);
|
|
4420
|
-
this.
|
|
4826
|
+
this.granted();
|
|
4421
4827
|
} catch (error) {
|
|
4422
|
-
this.
|
|
4828
|
+
this.computedError = error;
|
|
4423
4829
|
this.errored();
|
|
4424
4830
|
}
|
|
4425
4831
|
return this;
|
|
4426
4832
|
}
|
|
4427
|
-
|
|
4428
|
-
this.computedStatus = "
|
|
4833
|
+
granting() {
|
|
4834
|
+
this.computedStatus = "granting";
|
|
4429
4835
|
}
|
|
4430
|
-
|
|
4431
|
-
this.computedStatus = "
|
|
4836
|
+
granted() {
|
|
4837
|
+
this.computedStatus = "granted";
|
|
4432
4838
|
}
|
|
4433
4839
|
errored() {
|
|
4434
4840
|
this.computedStatus = "errored";
|
|
@@ -4624,9 +5030,6 @@ class Pickable {
|
|
|
4624
5030
|
get newest() {
|
|
4625
5031
|
return this.picks[this.picks.length - 1];
|
|
4626
5032
|
}
|
|
4627
|
-
get status() {
|
|
4628
|
-
return this.computedStatus;
|
|
4629
|
-
}
|
|
4630
5033
|
get items() {
|
|
4631
5034
|
return this.toItems(this.picks);
|
|
4632
5035
|
}
|
|
@@ -4635,6 +5038,9 @@ class Pickable {
|
|
|
4635
5038
|
get multiple() {
|
|
4636
5039
|
return this.computedMultiple;
|
|
4637
5040
|
}
|
|
5041
|
+
get status() {
|
|
5042
|
+
return this.computedStatus;
|
|
5043
|
+
}
|
|
4638
5044
|
toPossiblePicks;
|
|
4639
5045
|
setArray(array) {
|
|
4640
5046
|
this.computedArray = array;
|
|
@@ -4728,112 +5134,20 @@ function narrowIndices(indexOrIndices) {
|
|
|
4728
5134
|
}
|
|
4729
5135
|
const toUnique = createUnique();
|
|
4730
5136
|
|
|
4731
|
-
class Sanitizeable {
|
|
4732
|
-
domPurifyConfig;
|
|
4733
|
-
constructor(html, options) {
|
|
4734
|
-
this.computedHtml = html;
|
|
4735
|
-
this.domPurifyConfig = options;
|
|
4736
|
-
this.ready();
|
|
4737
|
-
}
|
|
4738
|
-
computedDompurify;
|
|
4739
|
-
computedStatus;
|
|
4740
|
-
ready() {
|
|
4741
|
-
if (getDomAvailability() === "available") {
|
|
4742
|
-
this.computedDompurify = createDOMPurify();
|
|
4743
|
-
this.computedDompurify.setConfig(this.domPurifyConfig);
|
|
4744
|
-
}
|
|
4745
|
-
this.computedStatus = "ready";
|
|
4746
|
-
}
|
|
4747
|
-
get html() {
|
|
4748
|
-
return this.computedHtml;
|
|
4749
|
-
}
|
|
4750
|
-
set html(html) {
|
|
4751
|
-
this.setHtml(html);
|
|
4752
|
-
}
|
|
4753
|
-
get dompurify() {
|
|
4754
|
-
if (!this.computedDompurify && getDomAvailability() === "available") {
|
|
4755
|
-
this.computedDompurify = createDOMPurify();
|
|
4756
|
-
this.computedDompurify.setConfig(this.domPurifyConfig);
|
|
4757
|
-
}
|
|
4758
|
-
return this.computedDompurify;
|
|
4759
|
-
}
|
|
4760
|
-
get status() {
|
|
4761
|
-
return this.computedStatus;
|
|
4762
|
-
}
|
|
4763
|
-
computedHtml;
|
|
4764
|
-
setHtml(html) {
|
|
4765
|
-
this.computedHtml = html;
|
|
4766
|
-
return this;
|
|
4767
|
-
}
|
|
4768
|
-
sanitize() {
|
|
4769
|
-
this.setHtml(this.dompurify.sanitize(this.html));
|
|
4770
|
-
this.sanitized();
|
|
4771
|
-
return this;
|
|
4772
|
-
}
|
|
4773
|
-
sanitized() {
|
|
4774
|
-
this.computedStatus = "sanitized";
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
4777
|
-
|
|
4778
|
-
class Searchable {
|
|
4779
|
-
searcherOptions;
|
|
4780
|
-
computedResults;
|
|
4781
|
-
constructor(candidates, options = {}) {
|
|
4782
|
-
this.searcherOptions = options;
|
|
4783
|
-
this.setCandidates(candidates);
|
|
4784
|
-
this.computedResults = [];
|
|
4785
|
-
this.ready();
|
|
4786
|
-
}
|
|
4787
|
-
computedStatus;
|
|
4788
|
-
ready() {
|
|
4789
|
-
this.computedStatus = "ready";
|
|
4790
|
-
}
|
|
4791
|
-
computedCandidates;
|
|
4792
|
-
get candidates() {
|
|
4793
|
-
return this.computedCandidates;
|
|
4794
|
-
}
|
|
4795
|
-
set candidates(candidates) {
|
|
4796
|
-
this.setCandidates(candidates);
|
|
4797
|
-
}
|
|
4798
|
-
get results() {
|
|
4799
|
-
return this.computedResults;
|
|
4800
|
-
}
|
|
4801
|
-
get searcher() {
|
|
4802
|
-
return this.computedSearcher;
|
|
4803
|
-
}
|
|
4804
|
-
get status() {
|
|
4805
|
-
return this.computedStatus;
|
|
4806
|
-
}
|
|
4807
|
-
computedSearcher;
|
|
4808
|
-
setCandidates(candidates) {
|
|
4809
|
-
this.computedCandidates = Array.from(candidates);
|
|
4810
|
-
this.computedSearcher = new Searcher(candidates, this.searcherOptions);
|
|
4811
|
-
return this;
|
|
4812
|
-
}
|
|
4813
|
-
search(query, options) {
|
|
4814
|
-
this.computedResults = this.searcher.search(query, options);
|
|
4815
|
-
this.searched();
|
|
4816
|
-
return this;
|
|
4817
|
-
}
|
|
4818
|
-
searched() {
|
|
4819
|
-
this.computedStatus = "searched";
|
|
4820
|
-
}
|
|
4821
|
-
}
|
|
4822
|
-
|
|
4823
5137
|
class Shareable {
|
|
4824
|
-
constructor(
|
|
4825
|
-
this.
|
|
5138
|
+
constructor(shareData, options = {}) {
|
|
5139
|
+
this.setShareData(shareData);
|
|
4826
5140
|
this.ready();
|
|
4827
5141
|
}
|
|
4828
5142
|
computedStatus;
|
|
4829
5143
|
ready() {
|
|
4830
5144
|
this.computedStatus = "ready";
|
|
4831
5145
|
}
|
|
4832
|
-
get
|
|
5146
|
+
get shareData() {
|
|
4833
5147
|
return this.computedState;
|
|
4834
5148
|
}
|
|
4835
|
-
set
|
|
4836
|
-
this.
|
|
5149
|
+
set shareData(shareData) {
|
|
5150
|
+
this.setShareData(shareData);
|
|
4837
5151
|
}
|
|
4838
5152
|
get status() {
|
|
4839
5153
|
return this.computedStatus;
|
|
@@ -4847,15 +5161,15 @@ class Shareable {
|
|
|
4847
5161
|
return this.computedError;
|
|
4848
5162
|
}
|
|
4849
5163
|
computedState;
|
|
4850
|
-
|
|
4851
|
-
this.computedState =
|
|
4852
|
-
this.computedCan = new Resolveable(async () => await navigator.canShare(
|
|
5164
|
+
setShareData(shareData) {
|
|
5165
|
+
this.computedState = shareData;
|
|
5166
|
+
this.computedCan = new Resolveable(async () => await navigator.canShare(shareData));
|
|
4853
5167
|
return this;
|
|
4854
5168
|
}
|
|
4855
5169
|
async share() {
|
|
4856
5170
|
this.sharing();
|
|
4857
5171
|
try {
|
|
4858
|
-
await navigator.share(this.
|
|
5172
|
+
await navigator.share(this.shareData);
|
|
4859
5173
|
this.shared();
|
|
4860
5174
|
} catch (error) {
|
|
4861
5175
|
this.computedError = error;
|
|
@@ -4995,4 +5309,4 @@ class Storeable {
|
|
|
4995
5309
|
}
|
|
4996
5310
|
}
|
|
4997
5311
|
|
|
4998
|
-
export { Animateable, Broadcastable, Compareable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Recognizeable, Resolveable,
|
|
5312
|
+
export { Animateable, Broadcastable, Compareable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Keychord, Keypress, Keyrelease, Konami, Listenable, Mousepress, Mouserelease, Navigateable, Pickable, Recognizeable, Resolveable, Shareable, Storeable, Touchpress, Touchrelease, createClear$2 as createAssociativeArrayClear, createDelete$2 as createAssociativeArrayDelete, createHas$1 as createAssociativeArrayHas, createKeys$1 as createAssociativeArrayKeys, createSet$2 as createAssociativeArraySet, createValue$2 as createAssociativeArrayValue, createValues$1 as createAssociativeArrayValues, createBreadthPathConfig, createChildren, createClamp, createClear$1 as createClear, createClip, createClone, createComputedStyle, createConcat, createAncestor$1 as createDecisionTreeAncestor, createCommonAncestors$1 as createDecisionTreeCommonAncestors, createNodeDepthFirstSteps$1 as createDecisionTreeNodeDepthFirstSteps, createPath$1 as createDecisionTreePath, createDepthFirstSteps$1 as createDecisionTreeSteps, createTree$1 as createDecisionTreeTree, createDeepEqual, createDeepMerge, createDelete$1 as createDelete, createDepthPathConfig, createDetermine, createAncestor$2 as createDirectedAcyclicAncestor, createAncestor as createDirectedAcyclicAsyncAncestor, createCommonAncestors as createDirectedAcyclicAsyncCommonAncestors, createDepthFirstSteps as createDirectedAcyclicAsyncDepthFirstSteps, createLayers as createDirectedAcyclicAsyncLayers, createNodeDepthFirstSteps as createDirectedAcyclicAsyncNodeDepthFirstSteps, createPath as createDirectedAcyclicAsyncPath, createTree as createDirectedAcyclicAsyncTree, createCommonAncestors$2 as createDirectedAcyclicCommonAncestors, createDepthFirstSteps$2 as createDirectedAcyclicDepthFirstSteps, createLayers$1 as createDirectedAcyclicLayers, createNodeDepthFirstSteps$2 as createDirectedAcyclicNodeDepthFirstSteps, createPath$2 as createDirectedAcyclicPath, createRoots as createDirectedAcyclicRoots, createTree$2 as createDirectedAcyclicTree, createEntries, createEqual, createEvery, createFilter, createFilterAsync, createFindAsync, createFindIndexAsync, createFocusable, createForEachAsync, createGraph, createGreater, createGreaterOrEqual, createHas, createIncoming, createIndegree, createInsert, createKeychord, createKeycomboMatch$1 as createKeycomboMatch, createKeypress, createKeyrelease, createKeys, createKonami, createLess, createLessOrEqual, createList, createMap, createMapAsync, createMix, createMousepress, createMouserelease, createNumber, createOnlyChild, createOutdegree, createOutgoing, createReduce, createReduceAsync, createRemove, createReorder, createReplace, createResults, createReverse, createRoot, createSanitize, createSet$1 as createSet, createShuffle, createSiblings, createSlice, createSlug, createSome, createSort, createSwap, createTerminal, createTotalSiblings, createTouchpress, createTouchrelease, createFind as createTreeFind, createUnique, createValue$1 as createValue, defineAssociativeArray, defineGraph, defineGraphAsync, defineGraphAsyncEdge, defineGraphAsyncEdges, 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, fromAliasToCode, fromCodeToAliases, fromKeyboardEventDescriptorToAliases, fromShorthandAliasToLonghandAlias, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
|