@baleada/logic 0.22.2 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +392 -148
- package/lib/index.d.ts +265 -208
- package/lib/index.js +386 -136
- package/package.json +20 -20
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reduce, pipe,
|
|
1
|
+
import { reduce, pipe, unique, toArray, slice, filter, map, concat, find, findIndex, some, every, join } from 'lazy-collections';
|
|
2
2
|
import slugify from '@sindresorhus/slugify';
|
|
3
3
|
import BezierEasing from 'bezier-easing';
|
|
4
4
|
import { mix } from '@snigo.dev/color';
|
|
@@ -9,10 +9,13 @@ import { Searcher } from 'fast-fuzzy';
|
|
|
9
9
|
|
|
10
10
|
function createReduceAsync(accumulate, initialValue) {
|
|
11
11
|
return async (array) => {
|
|
12
|
-
return await reduce(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return await reduce(
|
|
13
|
+
async (accumulatorPromise, item, index) => {
|
|
14
|
+
const accumulator = await accumulatorPromise;
|
|
15
|
+
return accumulate(accumulator, item, index);
|
|
16
|
+
},
|
|
17
|
+
Promise.resolve(initialValue)
|
|
18
|
+
)(array);
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
function createReduce(accumulate, initialValue) {
|
|
@@ -26,11 +29,14 @@ function createForEachAsync(forEach) {
|
|
|
26
29
|
}
|
|
27
30
|
function createMapAsync(transform) {
|
|
28
31
|
return async (array) => {
|
|
29
|
-
return await createReduceAsync(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
return await createReduceAsync(
|
|
33
|
+
async (resolvedMaps, item, index) => {
|
|
34
|
+
const transformed = await transform(item, index);
|
|
35
|
+
resolvedMaps.push(transformed);
|
|
36
|
+
return resolvedMaps;
|
|
37
|
+
},
|
|
38
|
+
[]
|
|
39
|
+
)(array);
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
function createFilterAsync(condition) {
|
|
@@ -41,13 +47,19 @@ function createFilterAsync(condition) {
|
|
|
41
47
|
}
|
|
42
48
|
function createDelete(index) {
|
|
43
49
|
return (array) => {
|
|
44
|
-
return createConcat(
|
|
50
|
+
return createConcat(
|
|
51
|
+
createSlice(0, index)(array),
|
|
52
|
+
createSlice(index + 1)(array)
|
|
53
|
+
)([]);
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
56
|
function createInsert(item, index) {
|
|
48
57
|
return (array) => {
|
|
49
58
|
const withItems = createConcat(array, [item])([]);
|
|
50
|
-
return createReorder(
|
|
59
|
+
return createReorder(
|
|
60
|
+
{ start: array.length, itemCount: 1 },
|
|
61
|
+
index
|
|
62
|
+
)(withItems);
|
|
51
63
|
};
|
|
52
64
|
}
|
|
53
65
|
function createReorder(from, to) {
|
|
@@ -59,11 +71,21 @@ function createReorder(from, to) {
|
|
|
59
71
|
const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
60
72
|
if (itemsToMoveStartIndex < insertIndex) {
|
|
61
73
|
const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
|
|
62
|
-
return createConcat(
|
|
74
|
+
return createConcat(
|
|
75
|
+
beforeItemsToMove,
|
|
76
|
+
betweenItemsToMoveAndInsertIndex,
|
|
77
|
+
itemsToMove,
|
|
78
|
+
afterInsertIndex
|
|
79
|
+
)([]);
|
|
63
80
|
}
|
|
64
81
|
if (itemsToMoveStartIndex > insertIndex) {
|
|
65
82
|
const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
66
|
-
return createConcat(
|
|
83
|
+
return createConcat(
|
|
84
|
+
beforeInsertion,
|
|
85
|
+
itemsToMove,
|
|
86
|
+
betweenInsertionAndItemsToMove,
|
|
87
|
+
afterItemsToMove
|
|
88
|
+
)([]);
|
|
67
89
|
}
|
|
68
90
|
return array;
|
|
69
91
|
};
|
|
@@ -96,25 +118,44 @@ function createSwap(indices) {
|
|
|
96
118
|
}
|
|
97
119
|
function createReplace(index, item) {
|
|
98
120
|
return (array) => {
|
|
99
|
-
return createConcat(
|
|
121
|
+
return createConcat(
|
|
122
|
+
createSlice(0, index)(array),
|
|
123
|
+
[item],
|
|
124
|
+
createSlice(index + 1)(array)
|
|
125
|
+
)([]);
|
|
100
126
|
};
|
|
101
127
|
}
|
|
102
128
|
function createUnique() {
|
|
103
|
-
return (array) => pipe(
|
|
129
|
+
return (array) => pipe(
|
|
130
|
+
unique(),
|
|
131
|
+
toArray()
|
|
132
|
+
)(array);
|
|
104
133
|
}
|
|
105
134
|
function createSlice(from, to) {
|
|
106
135
|
return (array) => {
|
|
107
|
-
return from === to ? [] : pipe(
|
|
136
|
+
return from === to ? [] : pipe(
|
|
137
|
+
slice(from, to - 1),
|
|
138
|
+
toArray()
|
|
139
|
+
)(array);
|
|
108
140
|
};
|
|
109
141
|
}
|
|
110
142
|
function createFilter(condition) {
|
|
111
|
-
return (array) => pipe(
|
|
143
|
+
return (array) => pipe(
|
|
144
|
+
filter(condition),
|
|
145
|
+
toArray()
|
|
146
|
+
)(array);
|
|
112
147
|
}
|
|
113
148
|
function createMap(transform) {
|
|
114
|
-
return (array) => pipe(
|
|
149
|
+
return (array) => pipe(
|
|
150
|
+
map(transform),
|
|
151
|
+
toArray()
|
|
152
|
+
)(array);
|
|
115
153
|
}
|
|
116
154
|
function createConcat(...arrays) {
|
|
117
|
-
return (array) => pipe(
|
|
155
|
+
return (array) => pipe(
|
|
156
|
+
concat(array, ...arrays),
|
|
157
|
+
toArray()
|
|
158
|
+
)();
|
|
118
159
|
}
|
|
119
160
|
function createReverse() {
|
|
120
161
|
return (array) => {
|
|
@@ -127,7 +168,10 @@ function createReverse() {
|
|
|
127
168
|
}
|
|
128
169
|
function createSort(compare) {
|
|
129
170
|
return (array) => {
|
|
130
|
-
return new Pipeable(array).pipe(
|
|
171
|
+
return new Pipeable(array).pipe(
|
|
172
|
+
createSlice(0),
|
|
173
|
+
(sliced) => compare ? sliced.sort(compare) : sliced.sort()
|
|
174
|
+
);
|
|
131
175
|
};
|
|
132
176
|
}
|
|
133
177
|
function createSlug(options) {
|
|
@@ -148,7 +192,10 @@ function createClamp(min, max) {
|
|
|
148
192
|
}
|
|
149
193
|
function createDetermine(potentialities) {
|
|
150
194
|
const predicates = createMap(({ outcome, probability }, index) => {
|
|
151
|
-
const lowerBound = index === 0 ? 0 : pipe(
|
|
195
|
+
const lowerBound = index === 0 ? 0 : pipe(
|
|
196
|
+
slice(0, index - 1),
|
|
197
|
+
reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
|
|
198
|
+
)(potentialities), upperBound = lowerBound + probability;
|
|
152
199
|
return {
|
|
153
200
|
outcome,
|
|
154
201
|
predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
|
|
@@ -179,7 +226,10 @@ class Pipeable {
|
|
|
179
226
|
return createReduce((piped, fn, index) => fn(piped, index), this.state)(fns);
|
|
180
227
|
}
|
|
181
228
|
async pipeAsync(...fns) {
|
|
182
|
-
return await createReduceAsync(
|
|
229
|
+
return await createReduceAsync(
|
|
230
|
+
async (piped, fn, index) => await fn(piped, index),
|
|
231
|
+
this.state
|
|
232
|
+
)(fns);
|
|
183
233
|
}
|
|
184
234
|
}
|
|
185
235
|
|
|
@@ -236,7 +286,10 @@ const keysByName = {
|
|
|
236
286
|
};
|
|
237
287
|
const toListenableKeycomboItems = createMap((name) => ({ name, type: fromComboItemNameToType(name) }));
|
|
238
288
|
function ensureKeycombo(type) {
|
|
239
|
-
return new Pipeable(type).pipe(
|
|
289
|
+
return new Pipeable(type).pipe(
|
|
290
|
+
toCombo,
|
|
291
|
+
toListenableKeycomboItems
|
|
292
|
+
);
|
|
240
293
|
}
|
|
241
294
|
function ensureClickcombo(type) {
|
|
242
295
|
return toCombo(type);
|
|
@@ -248,7 +301,11 @@ const toUnique$1 = unique();
|
|
|
248
301
|
const toComboItems = map((name) => name === "" ? delimiter : name);
|
|
249
302
|
const delimiter = "+";
|
|
250
303
|
function toCombo(type) {
|
|
251
|
-
return pipe(
|
|
304
|
+
return pipe(
|
|
305
|
+
toUnique$1,
|
|
306
|
+
toComboItems,
|
|
307
|
+
toArray()
|
|
308
|
+
)(type.split(delimiter));
|
|
252
309
|
}
|
|
253
310
|
function fromComboItemNameToType(name) {
|
|
254
311
|
return find((type) => predicatesByType[type](name))(listenableComboItemTypes) ?? "custom";
|
|
@@ -285,7 +342,7 @@ function createExceptAndOnlyEffect(type, effect, options) {
|
|
|
285
342
|
if (type === "keydown" || type === "keyup") {
|
|
286
343
|
return (event) => {
|
|
287
344
|
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
|
|
288
|
-
|
|
345
|
+
matches: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
|
|
289
346
|
};
|
|
290
347
|
if (matchesOnly) {
|
|
291
348
|
effect(event, api);
|
|
@@ -297,10 +354,10 @@ function createExceptAndOnlyEffect(type, effect, options) {
|
|
|
297
354
|
}
|
|
298
355
|
};
|
|
299
356
|
}
|
|
300
|
-
if (type === "click" || type === "
|
|
357
|
+
if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
|
|
301
358
|
return (event) => {
|
|
302
359
|
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
|
|
303
|
-
|
|
360
|
+
matches: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
|
|
304
361
|
};
|
|
305
362
|
if (matchesOnly) {
|
|
306
363
|
effect(event, api);
|
|
@@ -312,10 +369,10 @@ function createExceptAndOnlyEffect(type, effect, options) {
|
|
|
312
369
|
}
|
|
313
370
|
};
|
|
314
371
|
}
|
|
315
|
-
if (type
|
|
372
|
+
if (type.startsWith("pointer")) {
|
|
316
373
|
return (event) => {
|
|
317
374
|
const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
|
|
318
|
-
|
|
375
|
+
matches: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
|
|
319
376
|
};
|
|
320
377
|
if (matchesOnly) {
|
|
321
378
|
effect(event, api);
|
|
@@ -434,7 +491,10 @@ class Recognizeable {
|
|
|
434
491
|
}
|
|
435
492
|
recognize(sequenceItem, api, { onRecognized } = {}) {
|
|
436
493
|
this.recognizing();
|
|
437
|
-
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
|
|
494
|
+
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
|
|
495
|
+
createSlice(excess)(this.sequence),
|
|
496
|
+
[sequenceItem]
|
|
497
|
+
)([]);
|
|
438
498
|
this.effectApi.getSequence = () => newSequence;
|
|
439
499
|
this.effectApi.onRecognized = onRecognized || (() => {
|
|
440
500
|
});
|
|
@@ -534,6 +594,9 @@ class Listenable {
|
|
|
534
594
|
case "idle":
|
|
535
595
|
this.idleListen(effect, options);
|
|
536
596
|
break;
|
|
597
|
+
case "message":
|
|
598
|
+
this.messageListen(effect, options);
|
|
599
|
+
break;
|
|
537
600
|
case "recognizeable":
|
|
538
601
|
this.recognizeableListen(effect, options);
|
|
539
602
|
break;
|
|
@@ -575,6 +638,11 @@ class Listenable {
|
|
|
575
638
|
const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline, {}), requestIdleCallback);
|
|
576
639
|
this.active.add({ target: window, id });
|
|
577
640
|
}
|
|
641
|
+
messageListen(effect, options) {
|
|
642
|
+
const { target = new BroadcastChannel("baleada") } = options;
|
|
643
|
+
target.addEventListener(this.type, (event) => effect(event, {}));
|
|
644
|
+
this.active.add({ target, id: [this.type, effect] });
|
|
645
|
+
}
|
|
578
646
|
recognizeableListen(effect, options) {
|
|
579
647
|
const guardedEffect = (sequenceItem, api) => {
|
|
580
648
|
this.recognizeable.recognize(sequenceItem, api, { onRecognized: (sequenceItem2) => effect(sequenceItem2, api) });
|
|
@@ -642,7 +710,7 @@ function stop(stoppable) {
|
|
|
642
710
|
id2.disconnect();
|
|
643
711
|
return;
|
|
644
712
|
}
|
|
645
|
-
if (
|
|
713
|
+
if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
|
|
646
714
|
const { target: target2, id: id2 } = stoppable;
|
|
647
715
|
target2.removeEventListener(id2[0], id2[1]);
|
|
648
716
|
return;
|
|
@@ -652,6 +720,11 @@ function stop(stoppable) {
|
|
|
652
720
|
target2.cancelIdleCallback(id2);
|
|
653
721
|
return;
|
|
654
722
|
}
|
|
723
|
+
if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
|
|
724
|
+
const { target: target2, id: id2 } = stoppable;
|
|
725
|
+
target2.removeEventListener(id2[0], id2[1]);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
655
728
|
const { target, id } = stoppable;
|
|
656
729
|
target.removeEventListener(id[0], id[1], id[2]);
|
|
657
730
|
}
|
|
@@ -683,6 +756,10 @@ const predicatesByImplementation = /* @__PURE__ */ new Map([
|
|
|
683
756
|
"idle",
|
|
684
757
|
(type) => type === "idle"
|
|
685
758
|
],
|
|
759
|
+
[
|
|
760
|
+
"message",
|
|
761
|
+
(type) => type === "message" || type === "messageerror"
|
|
762
|
+
],
|
|
686
763
|
[
|
|
687
764
|
"documentevent",
|
|
688
765
|
(type) => documentEvents.has(type)
|
|
@@ -803,7 +880,7 @@ const observerAssertionsByType = {
|
|
|
803
880
|
resize: (observer) => observer instanceof ResizeObserver
|
|
804
881
|
};
|
|
805
882
|
|
|
806
|
-
const defaultOptions$
|
|
883
|
+
const defaultOptions$7 = {
|
|
807
884
|
duration: 0,
|
|
808
885
|
timing: [
|
|
809
886
|
0,
|
|
@@ -831,10 +908,10 @@ class Animateable {
|
|
|
831
908
|
getEaseables;
|
|
832
909
|
getReversedEaseables;
|
|
833
910
|
constructor(keyframes, options = {}) {
|
|
834
|
-
this.initialDuration = options?.duration || defaultOptions$
|
|
835
|
-
this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$
|
|
836
|
-
this.iterationLimit = options?.iterations || defaultOptions$
|
|
837
|
-
this.alternates = options?.alternates || defaultOptions$
|
|
911
|
+
this.initialDuration = options?.duration || defaultOptions$7.duration;
|
|
912
|
+
this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$7.timing);
|
|
913
|
+
this.iterationLimit = options?.iterations || defaultOptions$7.iterations;
|
|
914
|
+
this.alternates = options?.alternates || defaultOptions$7.alternates;
|
|
838
915
|
this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
|
|
839
916
|
this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
|
|
840
917
|
this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
|
|
@@ -910,7 +987,10 @@ class Animateable {
|
|
|
910
987
|
setKeyframes(keyframes) {
|
|
911
988
|
this.stop();
|
|
912
989
|
this.computedKeyframes = Array.from(keyframes).sort(({ progress: progressA }, { progress: progressB }) => progressA - progressB);
|
|
913
|
-
this.reversedKeyframes = new Pipeable(this.keyframes).pipe(
|
|
990
|
+
this.reversedKeyframes = new Pipeable(this.keyframes).pipe(
|
|
991
|
+
createReverse(),
|
|
992
|
+
createMap(({ progress, properties }) => ({ progress: 1 - progress, properties }))
|
|
993
|
+
);
|
|
914
994
|
this.properties = toProperties(this.keyframes);
|
|
915
995
|
this.easeables = this.getEaseables({ keyframes: this.keyframes, properties: this.properties });
|
|
916
996
|
this.reversedEaseables = this.getReversedEaseables({ keyframes: this.reversedKeyframes, properties: this.properties });
|
|
@@ -1180,14 +1260,20 @@ class Animateable {
|
|
|
1180
1260
|
return this.reversedEaseables;
|
|
1181
1261
|
}
|
|
1182
1262
|
})();
|
|
1183
|
-
return pipe(
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1263
|
+
return pipe(
|
|
1264
|
+
filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress),
|
|
1265
|
+
reduce(
|
|
1266
|
+
(frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
|
|
1267
|
+
const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
|
|
1268
|
+
frame.properties[property] = {
|
|
1269
|
+
progress: { time: timeProgress, animation: animationProgress },
|
|
1270
|
+
interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
|
|
1271
|
+
};
|
|
1272
|
+
return frame;
|
|
1273
|
+
},
|
|
1274
|
+
{ properties: {}, timestamp }
|
|
1275
|
+
)
|
|
1276
|
+
)(easeables);
|
|
1191
1277
|
}
|
|
1192
1278
|
recurse(type, timeRemaining, effect, options) {
|
|
1193
1279
|
switch (type) {
|
|
@@ -1444,26 +1530,36 @@ class Animateable {
|
|
|
1444
1530
|
}
|
|
1445
1531
|
function createGetEaseables(fromKeyframeToControlPoints) {
|
|
1446
1532
|
return ({ properties, keyframes }) => {
|
|
1447
|
-
const fromPropertiesToEasables = createReduce(
|
|
1448
|
-
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1533
|
+
const fromPropertiesToEasables = createReduce(
|
|
1534
|
+
(easeables, property) => {
|
|
1535
|
+
const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
|
|
1536
|
+
(propertyEaseables2, keyframe, index) => {
|
|
1537
|
+
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 ? (timeProgress) => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
|
|
1538
|
+
propertyEaseables2.push({
|
|
1539
|
+
property,
|
|
1540
|
+
value: { previous, next },
|
|
1541
|
+
progress: { start, end },
|
|
1542
|
+
hasCustomTiming,
|
|
1543
|
+
toAnimationProgress
|
|
1544
|
+
});
|
|
1545
|
+
return propertyEaseables2;
|
|
1546
|
+
},
|
|
1547
|
+
[]
|
|
1548
|
+
), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
|
|
1451
1549
|
property,
|
|
1452
|
-
value: { previous, next },
|
|
1453
|
-
progress: { start, end },
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
return
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
return createConcat(easeables, [firstEaseable], propertyEaseables)([]);
|
|
1466
|
-
}, []);
|
|
1550
|
+
value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
|
|
1551
|
+
progress: { start: -1, end: propertyEaseables[0].progress.start },
|
|
1552
|
+
toAnimationProgress: (timeProgress) => 1,
|
|
1553
|
+
hasCustomTiming: false
|
|
1554
|
+
};
|
|
1555
|
+
return createConcat(
|
|
1556
|
+
easeables,
|
|
1557
|
+
[firstEaseable],
|
|
1558
|
+
propertyEaseables
|
|
1559
|
+
)([]);
|
|
1560
|
+
},
|
|
1561
|
+
[]
|
|
1562
|
+
);
|
|
1467
1563
|
return fromPropertiesToEasables(properties);
|
|
1468
1564
|
};
|
|
1469
1565
|
}
|
|
@@ -1503,11 +1599,14 @@ function toInterpolated({ previous, next, progress }, options = {}) {
|
|
|
1503
1599
|
return (next - previous) * progress + previous;
|
|
1504
1600
|
}
|
|
1505
1601
|
if (isString(previous) && isString(next)) {
|
|
1506
|
-
return mix(
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1602
|
+
return mix(
|
|
1603
|
+
options.colorModel,
|
|
1604
|
+
{
|
|
1605
|
+
start: previous,
|
|
1606
|
+
end: next,
|
|
1607
|
+
alpha: progress
|
|
1608
|
+
}
|
|
1609
|
+
).toRgb().toRgbString();
|
|
1511
1610
|
}
|
|
1512
1611
|
if (isArray(previous) && isArray(next)) {
|
|
1513
1612
|
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;
|
|
@@ -1695,6 +1794,78 @@ const easingsNetInOutBack = [
|
|
|
1695
1794
|
1.6
|
|
1696
1795
|
];
|
|
1697
1796
|
|
|
1797
|
+
const defaultOptions$6 = {
|
|
1798
|
+
name: "baleada"
|
|
1799
|
+
};
|
|
1800
|
+
class Broadcastable {
|
|
1801
|
+
name;
|
|
1802
|
+
constructor(state, options = {}) {
|
|
1803
|
+
this.setState(state);
|
|
1804
|
+
this.name = options.name ?? defaultOptions$6.name;
|
|
1805
|
+
this.ready();
|
|
1806
|
+
}
|
|
1807
|
+
computedStatus;
|
|
1808
|
+
ready() {
|
|
1809
|
+
this.computedStatus = "ready";
|
|
1810
|
+
}
|
|
1811
|
+
get state() {
|
|
1812
|
+
return this.computedState;
|
|
1813
|
+
}
|
|
1814
|
+
set state(state) {
|
|
1815
|
+
this.setState(state);
|
|
1816
|
+
}
|
|
1817
|
+
get status() {
|
|
1818
|
+
return this.computedStatus;
|
|
1819
|
+
}
|
|
1820
|
+
computedChannel;
|
|
1821
|
+
get channel() {
|
|
1822
|
+
return this.computedChannel || (this.computedChannel = new BroadcastChannel(this.name));
|
|
1823
|
+
}
|
|
1824
|
+
computedError;
|
|
1825
|
+
get error() {
|
|
1826
|
+
return this.computedError;
|
|
1827
|
+
}
|
|
1828
|
+
computedState;
|
|
1829
|
+
setState(state) {
|
|
1830
|
+
this.computedState = state;
|
|
1831
|
+
return this;
|
|
1832
|
+
}
|
|
1833
|
+
broadcast() {
|
|
1834
|
+
this.broadcasting();
|
|
1835
|
+
try {
|
|
1836
|
+
this.channel.postMessage(this.state);
|
|
1837
|
+
this.broadcasted();
|
|
1838
|
+
} catch (error) {
|
|
1839
|
+
this.computedError = error;
|
|
1840
|
+
this.errored();
|
|
1841
|
+
}
|
|
1842
|
+
return this;
|
|
1843
|
+
}
|
|
1844
|
+
broadcasting() {
|
|
1845
|
+
this.computedStatus = "broadcasting";
|
|
1846
|
+
}
|
|
1847
|
+
broadcasted() {
|
|
1848
|
+
this.computedStatus = "broadcasted";
|
|
1849
|
+
}
|
|
1850
|
+
errored() {
|
|
1851
|
+
this.computedStatus = "errored";
|
|
1852
|
+
}
|
|
1853
|
+
stop() {
|
|
1854
|
+
this.channel.close();
|
|
1855
|
+
this.stopped();
|
|
1856
|
+
return this;
|
|
1857
|
+
}
|
|
1858
|
+
stopped() {
|
|
1859
|
+
this.computedStatus = "stopped";
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
function toMessageListenParams(instance, effect) {
|
|
1863
|
+
return [
|
|
1864
|
+
effect,
|
|
1865
|
+
{ target: instance.channel }
|
|
1866
|
+
];
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1698
1869
|
const defaultOptions$5 = {
|
|
1699
1870
|
segment: {
|
|
1700
1871
|
from: "start",
|
|
@@ -1743,7 +1914,10 @@ class Completeable {
|
|
|
1743
1914
|
return this.computedStatus;
|
|
1744
1915
|
}
|
|
1745
1916
|
get segment() {
|
|
1746
|
-
return this.string.slice(
|
|
1917
|
+
return this.string.slice(
|
|
1918
|
+
this.getSegmentStartIndex(),
|
|
1919
|
+
this.getSegmentEndIndex()
|
|
1920
|
+
);
|
|
1747
1921
|
}
|
|
1748
1922
|
get dividerIndices() {
|
|
1749
1923
|
return this.computedDividerIndices;
|
|
@@ -1856,7 +2030,12 @@ function toPreviousMatch({ string, re, from }) {
|
|
|
1856
2030
|
if (!re.test(string.slice(0, from)) || from === 0) {
|
|
1857
2031
|
indexOf = -1;
|
|
1858
2032
|
} else {
|
|
1859
|
-
const reversedStringBeforeFrom = new Pipeable(string).pipe(
|
|
2033
|
+
const reversedStringBeforeFrom = new Pipeable(string).pipe(
|
|
2034
|
+
(string2) => string2.slice(0, from),
|
|
2035
|
+
(sliced) => sliced.split(""),
|
|
2036
|
+
reverse,
|
|
2037
|
+
toString
|
|
2038
|
+
), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
|
|
1860
2039
|
indexOf = toNextMatchIndex === -1 ? -1 : reversedStringBeforeFrom.length - 1 - toNextMatchIndex;
|
|
1861
2040
|
}
|
|
1862
2041
|
return indexOf;
|
|
@@ -1948,7 +2127,7 @@ class Copyable {
|
|
|
1948
2127
|
errored() {
|
|
1949
2128
|
this.computedStatus = "errored";
|
|
1950
2129
|
}
|
|
1951
|
-
|
|
2130
|
+
listenForClipboardEvents() {
|
|
1952
2131
|
this.copyListenable.listen(this.copyAndCutEffect);
|
|
1953
2132
|
this.cutListenable.listen(this.copyAndCutEffect);
|
|
1954
2133
|
}
|
|
@@ -1965,13 +2144,16 @@ const defaultOptions$4 = {
|
|
|
1965
2144
|
class Delayable {
|
|
1966
2145
|
animateable;
|
|
1967
2146
|
constructor(effect, options = {}) {
|
|
1968
|
-
this.animateable = new Animateable(
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
2147
|
+
this.animateable = new Animateable(
|
|
2148
|
+
[
|
|
2149
|
+
{ progress: 0, properties: { progress: 0 } },
|
|
2150
|
+
{ progress: 1, properties: { progress: 1 } }
|
|
2151
|
+
],
|
|
2152
|
+
{
|
|
2153
|
+
duration: options?.delay ?? defaultOptions$4.delay,
|
|
2154
|
+
iterations: options?.executions ?? defaultOptions$4.executions
|
|
2155
|
+
}
|
|
2156
|
+
);
|
|
1975
2157
|
this.setEffect(effect);
|
|
1976
2158
|
this.ready();
|
|
1977
2159
|
}
|
|
@@ -2258,34 +2440,19 @@ class Fetchable {
|
|
|
2258
2440
|
return this.computedError;
|
|
2259
2441
|
}
|
|
2260
2442
|
get arrayBuffer() {
|
|
2261
|
-
return this.
|
|
2443
|
+
return this.computedArrayBuffer;
|
|
2262
2444
|
}
|
|
2263
2445
|
get blob() {
|
|
2264
|
-
return this.
|
|
2446
|
+
return this.computedBlob;
|
|
2265
2447
|
}
|
|
2266
2448
|
get formData() {
|
|
2267
|
-
return this.
|
|
2449
|
+
return this.computedFormData;
|
|
2268
2450
|
}
|
|
2269
2451
|
get json() {
|
|
2270
|
-
return this.
|
|
2452
|
+
return this.computedJson;
|
|
2271
2453
|
}
|
|
2272
2454
|
get text() {
|
|
2273
|
-
return this.
|
|
2274
|
-
}
|
|
2275
|
-
getUsedBody(resolveable) {
|
|
2276
|
-
const bodyUsed = "bodyUsed" in this.response ? this.response.bodyUsed : false;
|
|
2277
|
-
if (!bodyUsed) {
|
|
2278
|
-
return resolveable.resolve();
|
|
2279
|
-
}
|
|
2280
|
-
switch (resolveable.status) {
|
|
2281
|
-
case "ready":
|
|
2282
|
-
break;
|
|
2283
|
-
case "resolving":
|
|
2284
|
-
break;
|
|
2285
|
-
case "resolved":
|
|
2286
|
-
case "errored":
|
|
2287
|
-
return resolveable;
|
|
2288
|
-
}
|
|
2455
|
+
return this.computedText;
|
|
2289
2456
|
}
|
|
2290
2457
|
computedResource;
|
|
2291
2458
|
setResource(resource) {
|
|
@@ -2295,16 +2462,31 @@ class Fetchable {
|
|
|
2295
2462
|
computedResponse;
|
|
2296
2463
|
computedError;
|
|
2297
2464
|
async fetch(options = {}) {
|
|
2298
|
-
this.
|
|
2465
|
+
this.fetching();
|
|
2299
2466
|
try {
|
|
2300
2467
|
this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...ensureOptions(options) });
|
|
2301
|
-
this.
|
|
2468
|
+
this.fetched();
|
|
2302
2469
|
} catch (error) {
|
|
2303
2470
|
this.computedError = error;
|
|
2304
|
-
|
|
2471
|
+
if (error.name === "AbortError")
|
|
2472
|
+
this.aborted();
|
|
2473
|
+
else
|
|
2474
|
+
this.errored();
|
|
2305
2475
|
}
|
|
2306
2476
|
return this;
|
|
2307
2477
|
}
|
|
2478
|
+
fetching() {
|
|
2479
|
+
this.computedStatus = "fetching";
|
|
2480
|
+
}
|
|
2481
|
+
fetched() {
|
|
2482
|
+
this.computedStatus = "fetched";
|
|
2483
|
+
}
|
|
2484
|
+
aborted() {
|
|
2485
|
+
this.computedStatus = "aborted";
|
|
2486
|
+
}
|
|
2487
|
+
errored() {
|
|
2488
|
+
this.computedStatus = "errored";
|
|
2489
|
+
}
|
|
2308
2490
|
async get(options = {}) {
|
|
2309
2491
|
await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "get" });
|
|
2310
2492
|
return this;
|
|
@@ -2668,38 +2850,50 @@ class Pickable {
|
|
|
2668
2850
|
}
|
|
2669
2851
|
pick(indexOrIndices, options = {}) {
|
|
2670
2852
|
const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
|
|
2671
|
-
this.computedPicks = new Pipeable(indexOrIndices).pipe(
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2853
|
+
this.computedPicks = new Pipeable(indexOrIndices).pipe(
|
|
2854
|
+
ensureIndices,
|
|
2855
|
+
this.toPossiblePicks,
|
|
2856
|
+
(possiblePicks) => {
|
|
2857
|
+
if (replace === "all") {
|
|
2858
|
+
return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
|
|
2859
|
+
}
|
|
2860
|
+
const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter(
|
|
2861
|
+
(possiblePick) => typeof find((pick) => pick === possiblePick)(this.picks || []) !== "number"
|
|
2862
|
+
)(possiblePicks);
|
|
2863
|
+
switch (replace) {
|
|
2864
|
+
case "none":
|
|
2865
|
+
return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
|
|
2866
|
+
case "fifo":
|
|
2867
|
+
if (maybeWithoutDuplicates.length === 0) {
|
|
2868
|
+
return this.picks;
|
|
2869
|
+
}
|
|
2870
|
+
if (maybeWithoutDuplicates.length === this.picks.length) {
|
|
2871
|
+
return maybeWithoutDuplicates;
|
|
2872
|
+
}
|
|
2873
|
+
if (maybeWithoutDuplicates.length > this.picks.length) {
|
|
2874
|
+
return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
|
|
2875
|
+
}
|
|
2876
|
+
return new Pipeable(this.picks).pipe(
|
|
2877
|
+
createSlice(maybeWithoutDuplicates.length),
|
|
2878
|
+
createConcat(maybeWithoutDuplicates)
|
|
2879
|
+
);
|
|
2880
|
+
case "lifo":
|
|
2881
|
+
if (maybeWithoutDuplicates.length === 0) {
|
|
2882
|
+
return this.picks;
|
|
2883
|
+
}
|
|
2884
|
+
if (maybeWithoutDuplicates.length === this.picks.length) {
|
|
2885
|
+
return maybeWithoutDuplicates;
|
|
2886
|
+
}
|
|
2887
|
+
if (maybeWithoutDuplicates.length > this.picks.length) {
|
|
2888
|
+
return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
|
|
2889
|
+
}
|
|
2890
|
+
return new Pipeable(this.picks).pipe(
|
|
2891
|
+
createSlice(0, this.picks.length - maybeWithoutDuplicates.length),
|
|
2892
|
+
createConcat(maybeWithoutDuplicates)
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2701
2895
|
}
|
|
2702
|
-
|
|
2896
|
+
);
|
|
2703
2897
|
this.computedFirst = Math.min(...this.picks);
|
|
2704
2898
|
this.computedLast = Math.max(...this.picks);
|
|
2705
2899
|
this.computedMultiple = toUnique(this.picks).length > 1;
|
|
@@ -2719,7 +2913,9 @@ class Pickable {
|
|
|
2719
2913
|
return this;
|
|
2720
2914
|
}
|
|
2721
2915
|
const omits = ensureIndices(indexOrIndices);
|
|
2722
|
-
this.computedPicks = createFilter(
|
|
2916
|
+
this.computedPicks = createFilter(
|
|
2917
|
+
(pick, index) => options.reference === "array" ? isUndefined(find((omit) => pick === omit)(omits)) : isUndefined(find((omit) => index === omit)(omits))
|
|
2918
|
+
)(this.computedPicks);
|
|
2723
2919
|
this.computedFirst = Math.min(...this.picks);
|
|
2724
2920
|
this.computedLast = Math.max(...this.picks);
|
|
2725
2921
|
this.computedMultiple = toUnique(this.picks).length > 1;
|
|
@@ -2827,6 +3023,60 @@ class Searchable {
|
|
|
2827
3023
|
}
|
|
2828
3024
|
}
|
|
2829
3025
|
|
|
3026
|
+
class Shareable {
|
|
3027
|
+
constructor(state, options = {}) {
|
|
3028
|
+
this.setState(state);
|
|
3029
|
+
this.ready();
|
|
3030
|
+
}
|
|
3031
|
+
computedStatus;
|
|
3032
|
+
ready() {
|
|
3033
|
+
this.computedStatus = "ready";
|
|
3034
|
+
}
|
|
3035
|
+
get state() {
|
|
3036
|
+
return this.computedState;
|
|
3037
|
+
}
|
|
3038
|
+
set state(state) {
|
|
3039
|
+
this.setState(state);
|
|
3040
|
+
}
|
|
3041
|
+
get status() {
|
|
3042
|
+
return this.computedStatus;
|
|
3043
|
+
}
|
|
3044
|
+
computedCan;
|
|
3045
|
+
get can() {
|
|
3046
|
+
return this.computedCan;
|
|
3047
|
+
}
|
|
3048
|
+
computedError;
|
|
3049
|
+
get error() {
|
|
3050
|
+
return this.computedError;
|
|
3051
|
+
}
|
|
3052
|
+
computedState;
|
|
3053
|
+
setState(state) {
|
|
3054
|
+
this.computedState = state;
|
|
3055
|
+
this.computedCan = new Resolveable(async () => await navigator.canShare(state));
|
|
3056
|
+
return this;
|
|
3057
|
+
}
|
|
3058
|
+
async share() {
|
|
3059
|
+
this.sharing();
|
|
3060
|
+
try {
|
|
3061
|
+
await navigator.share(this.state);
|
|
3062
|
+
this.shared();
|
|
3063
|
+
} catch (error) {
|
|
3064
|
+
this.computedError = error;
|
|
3065
|
+
this.errored();
|
|
3066
|
+
}
|
|
3067
|
+
return this;
|
|
3068
|
+
}
|
|
3069
|
+
sharing() {
|
|
3070
|
+
this.computedStatus = "sharing";
|
|
3071
|
+
}
|
|
3072
|
+
shared() {
|
|
3073
|
+
this.computedStatus = "shared";
|
|
3074
|
+
}
|
|
3075
|
+
errored() {
|
|
3076
|
+
this.computedStatus = "errored";
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
|
|
2830
3080
|
const defaultOptions = {
|
|
2831
3081
|
kind: "local",
|
|
2832
3082
|
statusKeySuffix: " status"
|
|
@@ -2948,4 +3198,4 @@ class Storeable {
|
|
|
2948
3198
|
}
|
|
2949
3199
|
}
|
|
2950
3200
|
|
|
2951
|
-
export { Animateable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
|
|
3201
|
+
export { Animateable, Broadcastable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
|