@baleada/logic 0.24.12 → 0.24.13
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 +66 -18
- package/lib/index.d.ts +24 -12
- package/lib/index.js +65 -19
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -892,10 +892,19 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
892
892
|
toCode,
|
|
893
893
|
toAliases,
|
|
894
894
|
getRequest: () => request
|
|
895
|
-
}), fromComboToAliasesLength = createAliasesLength({ toLonghand })
|
|
896
|
-
|
|
897
|
-
|
|
895
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand }), maybeAddWindowBlurListener = () => {
|
|
896
|
+
if (windowBlurStatus === "added")
|
|
897
|
+
return;
|
|
898
|
+
window.addEventListener("blur", onWindowBlur);
|
|
899
|
+
windowBlurStatus = "added";
|
|
900
|
+
}, onWindowBlur = () => {
|
|
901
|
+
clearStatuses();
|
|
902
|
+
localStatus = "recognizing";
|
|
903
|
+
stop();
|
|
904
|
+
};
|
|
905
|
+
let request, localStatus, windowBlurStatus = "removed";
|
|
898
906
|
const keydown = (event, api) => {
|
|
907
|
+
maybeAddWindowBlurListener();
|
|
899
908
|
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
900
909
|
if (toStatus(key) === "down") {
|
|
901
910
|
onDown?.(toHookApi(api));
|
|
@@ -973,15 +982,17 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
973
982
|
onUp?.(toHookApi(api));
|
|
974
983
|
};
|
|
975
984
|
const visibilitychange = (event, api) => {
|
|
976
|
-
if (document.visibilityState === "hidden")
|
|
977
|
-
|
|
978
|
-
localStatus = "recognizing";
|
|
979
|
-
stop();
|
|
980
|
-
}
|
|
985
|
+
if (document.visibilityState === "hidden")
|
|
986
|
+
onWindowBlur();
|
|
981
987
|
onVisibilitychange?.(toHookApi(api));
|
|
982
988
|
};
|
|
983
989
|
return {
|
|
984
|
-
keydown
|
|
990
|
+
keydown: {
|
|
991
|
+
effect: keydown,
|
|
992
|
+
stop: () => {
|
|
993
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
994
|
+
}
|
|
995
|
+
},
|
|
985
996
|
keyup,
|
|
986
997
|
visibilitychange
|
|
987
998
|
};
|
|
@@ -1034,9 +1045,19 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1034
1045
|
toCode,
|
|
1035
1046
|
toAliases,
|
|
1036
1047
|
getRequest: () => request
|
|
1037
|
-
}), fromComboToAliasesLength = createAliasesLength({ toLonghand })
|
|
1038
|
-
|
|
1048
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand }), maybeAddWindowBlurListener = () => {
|
|
1049
|
+
if (windowBlurStatus === "added")
|
|
1050
|
+
return;
|
|
1051
|
+
window.addEventListener("blur", onWindowBlur);
|
|
1052
|
+
windowBlurStatus = "added";
|
|
1053
|
+
}, onWindowBlur = () => {
|
|
1054
|
+
clearStatuses();
|
|
1055
|
+
localStatus = "recognizing";
|
|
1056
|
+
stop();
|
|
1057
|
+
};
|
|
1058
|
+
let request, localStatus, windowBlurStatus = "removed";
|
|
1039
1059
|
const keydown = (event, api) => {
|
|
1060
|
+
maybeAddWindowBlurListener();
|
|
1040
1061
|
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
1041
1062
|
if (toStatus(key) === "down") {
|
|
1042
1063
|
onDown?.(toHookApi(api));
|
|
@@ -1125,7 +1146,12 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1125
1146
|
onVisibilitychange?.(toHookApi(api));
|
|
1126
1147
|
};
|
|
1127
1148
|
return {
|
|
1128
|
-
keydown
|
|
1149
|
+
keydown: {
|
|
1150
|
+
effect: keydown,
|
|
1151
|
+
stop: () => {
|
|
1152
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1129
1155
|
keyup,
|
|
1130
1156
|
visibilitychange
|
|
1131
1157
|
};
|
|
@@ -1496,9 +1522,9 @@ function createMouserelease(options = {}) {
|
|
|
1496
1522
|
const { getMetadata, recognized, denied } = api, metadata = getMetadata();
|
|
1497
1523
|
if (metadata.duration >= minDuration && metadata.distance.straight.fromStart >= minDistance && metadata.velocity >= minVelocity) {
|
|
1498
1524
|
recognized();
|
|
1499
|
-
|
|
1500
|
-
denied();
|
|
1525
|
+
return;
|
|
1501
1526
|
}
|
|
1527
|
+
denied();
|
|
1502
1528
|
};
|
|
1503
1529
|
return {
|
|
1504
1530
|
mousedown: {
|
|
@@ -2272,6 +2298,26 @@ function createComputedStyle(pseudoElement) {
|
|
|
2272
2298
|
return (element) => getComputedStyle(element, pseudoElement);
|
|
2273
2299
|
}
|
|
2274
2300
|
|
|
2301
|
+
function createTry() {
|
|
2302
|
+
return (fn) => {
|
|
2303
|
+
try {
|
|
2304
|
+
return fn();
|
|
2305
|
+
} catch (error) {
|
|
2306
|
+
return error;
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
function createTryAsync() {
|
|
2312
|
+
return async (fn) => {
|
|
2313
|
+
try {
|
|
2314
|
+
return await fn();
|
|
2315
|
+
} catch (error) {
|
|
2316
|
+
return error;
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2275
2321
|
const defaultOptions$c = {
|
|
2276
2322
|
toCode: (alias) => fromAliasToCode(alias),
|
|
2277
2323
|
toAliases: (descriptor) => fromKeyboardEventDescriptorToAliases(descriptor)
|
|
@@ -2943,12 +2989,12 @@ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recogn
|
|
|
2943
2989
|
}
|
|
2944
2990
|
metadata.times.start = Math.round(event.timeStamp);
|
|
2945
2991
|
metadata.times.end = Math.round(event.timeStamp);
|
|
2946
|
-
let
|
|
2992
|
+
let previousEndTime = metadata.times.start;
|
|
2947
2993
|
const frameEffect = (timestamp) => {
|
|
2948
|
-
|
|
2994
|
+
previousEndTime = metadata.times.end;
|
|
2949
2995
|
metadata.times.end = Math.round(timestamp);
|
|
2950
2996
|
metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
|
|
2951
|
-
const durationFromPrevious = Math.max(0, metadata.times.end -
|
|
2997
|
+
const durationFromPrevious = Math.max(0, metadata.times.end - previousEndTime);
|
|
2952
2998
|
metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious || 0;
|
|
2953
2999
|
const event2 = getSequence().at(-1);
|
|
2954
3000
|
recognize?.(event2, api);
|
|
@@ -2956,7 +3002,7 @@ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recogn
|
|
|
2956
3002
|
effect(event2);
|
|
2957
3003
|
}, storeDuration = () => {
|
|
2958
3004
|
const sequence = api.getSequence();
|
|
2959
|
-
if (!document.
|
|
3005
|
+
if (!document.contains(
|
|
2960
3006
|
lazyCollections.at(-1)(sequence).target
|
|
2961
3007
|
))
|
|
2962
3008
|
return;
|
|
@@ -5540,6 +5586,8 @@ exports.createTotalSiblings = createTotalSiblings;
|
|
|
5540
5586
|
exports.createTouchpress = createTouchpress;
|
|
5541
5587
|
exports.createTouchrelease = createTouchrelease;
|
|
5542
5588
|
exports.createTreeFind = createFind;
|
|
5589
|
+
exports.createTry = createTry;
|
|
5590
|
+
exports.createTryAsync = createTryAsync;
|
|
5543
5591
|
exports.createUnique = createUnique;
|
|
5544
5592
|
exports.createValue = createValue$1;
|
|
5545
5593
|
exports.defineAssociativeArray = defineAssociativeArray;
|
package/lib/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ type AssociativeArrayEffect<Key, Value> = (associativeArray: AssociativeArray<Ke
|
|
|
107
107
|
/**
|
|
108
108
|
* [Docs](https://baleada.dev/docs/logic/links/associative-array-set)
|
|
109
109
|
*/
|
|
110
|
-
declare function createSet$1<Key extends any, Value extends any>(key: Key, value: Value, options?: WithPredicateKey): AssociativeArrayEffect<Key, Value>;
|
|
110
|
+
declare function createSet$1<Key extends any, Value extends any>(key: Key, value: Value, options?: WithPredicateKey<Key>): AssociativeArrayEffect<Key, Value>;
|
|
111
111
|
/**
|
|
112
112
|
* [Docs](https://baleada.dev/docs/logic/links/associative-array-clear)
|
|
113
113
|
*/
|
|
@@ -115,7 +115,7 @@ declare function createClear$1<Key extends any, Value extends any>(): Associativ
|
|
|
115
115
|
/**
|
|
116
116
|
* [Docs](https://baleada.dev/docs/logic/links/associative-array-delete)
|
|
117
117
|
*/
|
|
118
|
-
declare function createDelete$1<Key extends any>(key: Key, options?: WithPredicateKey): AssociativeArrayEffect<Key, any>;
|
|
118
|
+
declare function createDelete$1<Key extends any>(key: Key, options?: WithPredicateKey<Key>): AssociativeArrayEffect<Key, any>;
|
|
119
119
|
|
|
120
120
|
type AssociativeArray<Key, Value> = [Key, Value][];
|
|
121
121
|
|
|
@@ -388,14 +388,14 @@ declare class Listenable<Type extends ListenableSupportedType, RecognizeableMeta
|
|
|
388
388
|
constructor(type: Type, options?: ListenableOptions<Type, RecognizeableMetadata>);
|
|
389
389
|
private computedStatus;
|
|
390
390
|
private ready;
|
|
391
|
-
get type():
|
|
392
|
-
set type(type:
|
|
391
|
+
get type(): Type;
|
|
392
|
+
set type(type: Type);
|
|
393
393
|
get status(): ListenableStatus;
|
|
394
394
|
get active(): Set<ListenableActive<Type, RecognizeableMetadata>>;
|
|
395
395
|
get recognizeable(): Recognizeable<Type, RecognizeableMetadata>;
|
|
396
396
|
private computedType;
|
|
397
397
|
private implementation;
|
|
398
|
-
setType(type:
|
|
398
|
+
setType(type: Type): this;
|
|
399
399
|
listen(effect: ListenEffect<Type>, options?: ListenOptions<Type>): this;
|
|
400
400
|
private intersectionListen;
|
|
401
401
|
private mutationListen;
|
|
@@ -416,17 +416,17 @@ declare class Listenable<Type extends ListenableSupportedType, RecognizeableMeta
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
type AssociativeArrayTransform<Key, Value, Transformed> = (associativeArray: AssociativeArray<Key, Value>) => Transformed;
|
|
419
|
-
type WithPredicateKey = {
|
|
420
|
-
predicateKey?: (candidate:
|
|
419
|
+
type WithPredicateKey<Key extends any> = {
|
|
420
|
+
predicateKey?: (candidate: Key) => boolean;
|
|
421
421
|
};
|
|
422
422
|
/**
|
|
423
423
|
* [Docs](https://baleada.dev/docs/logic/pipes/associative-array-value)
|
|
424
424
|
*/
|
|
425
|
-
declare function createValue$1<Key extends any, Value extends any>(key: Key, options?: WithPredicateKey): AssociativeArrayTransform<Key, Value, Value | undefined>;
|
|
425
|
+
declare function createValue$1<Key extends any, Value extends any>(key: Key, options?: WithPredicateKey<Key>): AssociativeArrayTransform<Key, Value, Value | undefined>;
|
|
426
426
|
/**
|
|
427
427
|
* [Docs](https://baleada.dev/docs/logic/pipes/associative-array-has)
|
|
428
428
|
*/
|
|
429
|
-
declare function createHas$1<Key extends any>(key: Key, options?: WithPredicateKey): AssociativeArrayTransform<Key, any, boolean>;
|
|
429
|
+
declare function createHas$1<Key extends any>(key: Key, options?: WithPredicateKey<Key>): AssociativeArrayTransform<Key, any, boolean>;
|
|
430
430
|
/**
|
|
431
431
|
* [Docs](https://baleada.dev/docs/logic/pipes/associative-array-keys)
|
|
432
432
|
*/
|
|
@@ -644,6 +644,12 @@ declare function createFocusable(order: 'first' | 'last' | 'next' | 'previous',
|
|
|
644
644
|
*/
|
|
645
645
|
declare function createComputedStyle(pseudoElement?: string): ElementTransform<HTMLElement, CSSStyleDeclaration>;
|
|
646
646
|
|
|
647
|
+
type FunctionTransform<Fn extends Function, Returned> = (param: Fn) => Returned;
|
|
648
|
+
declare function createTry<Optimistic, Pessimistic extends Error>(): FunctionTransform<() => Optimistic, Optimistic | Pessimistic>;
|
|
649
|
+
|
|
650
|
+
type AsyncFunctionTransform<Fn extends Function, Returned> = (param: Fn) => Promise<Returned>;
|
|
651
|
+
declare function createTryAsync<Optimistic, Pessimistic extends Error>(): AsyncFunctionTransform<() => Promise<Optimistic>, Optimistic | Pessimistic>;
|
|
652
|
+
|
|
647
653
|
type GraphTreeTransform<Id extends string, Transformed> = (tree: GraphTree<Id>) => Transformed;
|
|
648
654
|
/**
|
|
649
655
|
* [Docs](https://baleada.dev/docs/logic/pipes/find)
|
|
@@ -1447,7 +1453,10 @@ type KeypressOptions = CreateKeycomboMatchOptions$1 & {
|
|
|
1447
1453
|
type KeypressHook = (api: KeypressHookApi) => any;
|
|
1448
1454
|
type KeypressHookApi = HookApi<KeypressType, KeypressMetadata>;
|
|
1449
1455
|
declare function createKeypress(keycomboOrKeycombos: string | string[], options?: KeypressOptions): {
|
|
1450
|
-
keydown:
|
|
1456
|
+
keydown: {
|
|
1457
|
+
effect: RecognizeableEffect<"keydown", KeypressMetadata>;
|
|
1458
|
+
stop: () => void;
|
|
1459
|
+
};
|
|
1451
1460
|
keyup: RecognizeableEffect<"keyup", KeypressMetadata>;
|
|
1452
1461
|
visibilitychange: RecognizeableEffect<"visibilitychange", KeypressMetadata>;
|
|
1453
1462
|
};
|
|
@@ -1470,7 +1479,10 @@ type KeyreleaseOptions = CreateKeycomboMatchOptions$1 & {
|
|
|
1470
1479
|
type KeyreleaseHook = (api: KeyreleaseHookApi) => any;
|
|
1471
1480
|
type KeyreleaseHookApi = HookApi<KeyreleaseType, KeyreleaseMetadata>;
|
|
1472
1481
|
declare function createKeyrelease(keycomboOrKeycombos: string | string[], options?: KeyreleaseOptions): {
|
|
1473
|
-
keydown:
|
|
1482
|
+
keydown: {
|
|
1483
|
+
effect: RecognizeableEffect<"keydown", KeyreleaseMetadata>;
|
|
1484
|
+
stop: () => void;
|
|
1485
|
+
};
|
|
1474
1486
|
keyup: RecognizeableEffect<"keyup", KeyreleaseMetadata>;
|
|
1475
1487
|
visibilitychange: RecognizeableEffect<"visibilitychange", KeyreleaseMetadata>;
|
|
1476
1488
|
};
|
|
@@ -1624,4 +1636,4 @@ declare class Touchrelease extends Listenable<TouchreleaseType, TouchreleaseMeta
|
|
|
1624
1636
|
get metadata(): TouchreleaseMetadata;
|
|
1625
1637
|
}
|
|
1626
1638
|
|
|
1627
|
-
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, Broadcastable, BroadcastableOptions, BroadcastableStatus, ColorInterpolationMethod, Compareable, CompareableOptions, CompareableStatus, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, CreateStepsOptions$1 as CreateDirectedAcyclicStepsOptions, CreateFocusableOptions, CreateGraphOptions, CreateKeycomboMatchOptions, CreateMixOptions, CreatePathConfig, CreateResultsOptions, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, Drawable, DrawableOptions, DrawableStatus, DrawableStroke, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, Keychord, KeychordHook, KeychordHookApi, KeychordMetadata, KeychordOptions, KeychordType, Keypress, KeypressHook, KeypressHookApi, KeypressMetadata, KeypressOptions, KeypressType, Keyrelease, KeyreleaseHook, KeyreleaseHookApi, KeyreleaseMetadata, KeyreleaseOptions, KeyreleaseType, Konami, KonamiHook, KonamiHookApi, KonamiMetadata, KonamiOptions, KonamiType, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableKeycombo, ListenableMousecombo, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MixColor, Mousepress, MousepressHook, MousepressHookApi, MousepressMetadata, MousepressOptions, MousepressType, Mouserelease, MousereleaseHook, MousereleaseHookApi, MousereleaseMetadata, MousereleaseOptions, MousereleaseType, Navigateable, NavigateableOptions, NavigateableStatus, PickOptions, Pickable, PickableOptions, PickableStatus, Potentiality, RecognizeOptions, Recognizeable, RecognizeableEffect, RecognizeableEffectConfig, RecognizeableOptions, RecognizeableStatus, RecognizeableStopTarget, Resolveable, ResolveableOptions, ResolveableStatus, Shareable, ShareableOptions, ShareableStatus, Storeable, StoreableOptions, StoreableStatus, ToGraphYielded, Touchpress, TouchpressHook, TouchpressHookApi, TouchpressMetadata, TouchpressOptions, TouchpressType, Touchrelease, TouchreleaseHook, TouchreleaseHookApi, TouchreleaseMetadata, TouchreleaseOptions, TouchreleaseType, createClear$1 as createAssociativeArrayClear, createDelete$1 as createAssociativeArrayDelete, createHas$1 as createAssociativeArrayHas, createKeys$1 as createAssociativeArrayKeys, createSet$1 as createAssociativeArraySet, createValue$1 as createAssociativeArrayValue, createValues as createAssociativeArrayValues, createBreadthPathConfig, createChildren, createClamp, 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, 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, createKeypress, createKeyrelease, createKeys, createKonami, createLess, createLessOrEqual, createList, createMap, createMapAsync, createMix, createMousepress, createMouserelease, createNumber, createOmit, createOnlyChild, createOutdegree, createOutgoing, createPick, createReduce, createReduceAsync, createRemove, createReorder, createReplace, createResults, createReverse, createRoot, createSanitize, createSet, createShuffle, createSiblings, createSlice, createSlug, createSome, createSort, createSwap, createTerminal, createTotalSiblings, createTouchpress, createTouchrelease, createFind as createTreeFind, createUnique, createValue, 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 };
|
|
1639
|
+
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, Broadcastable, BroadcastableOptions, BroadcastableStatus, ColorInterpolationMethod, Compareable, CompareableOptions, CompareableStatus, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, CreateStepsOptions$1 as CreateDirectedAcyclicStepsOptions, CreateFocusableOptions, CreateGraphOptions, CreateKeycomboMatchOptions, CreateMixOptions, CreatePathConfig, CreateResultsOptions, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, Drawable, DrawableOptions, DrawableStatus, DrawableStroke, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, Keychord, KeychordHook, KeychordHookApi, KeychordMetadata, KeychordOptions, KeychordType, Keypress, KeypressHook, KeypressHookApi, KeypressMetadata, KeypressOptions, KeypressType, Keyrelease, KeyreleaseHook, KeyreleaseHookApi, KeyreleaseMetadata, KeyreleaseOptions, KeyreleaseType, Konami, KonamiHook, KonamiHookApi, KonamiMetadata, KonamiOptions, KonamiType, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableKeycombo, ListenableMousecombo, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MixColor, Mousepress, MousepressHook, MousepressHookApi, MousepressMetadata, MousepressOptions, MousepressType, Mouserelease, MousereleaseHook, MousereleaseHookApi, MousereleaseMetadata, MousereleaseOptions, MousereleaseType, Navigateable, NavigateableOptions, NavigateableStatus, PickOptions, Pickable, PickableOptions, PickableStatus, Potentiality, RecognizeOptions, Recognizeable, RecognizeableEffect, RecognizeableEffectConfig, RecognizeableOptions, RecognizeableStatus, RecognizeableStopTarget, Resolveable, ResolveableOptions, ResolveableStatus, Shareable, ShareableOptions, ShareableStatus, Storeable, StoreableOptions, StoreableStatus, ToGraphYielded, Touchpress, TouchpressHook, TouchpressHookApi, TouchpressMetadata, TouchpressOptions, TouchpressType, Touchrelease, TouchreleaseHook, TouchreleaseHookApi, TouchreleaseMetadata, TouchreleaseOptions, TouchreleaseType, createClear$1 as createAssociativeArrayClear, createDelete$1 as createAssociativeArrayDelete, createHas$1 as createAssociativeArrayHas, createKeys$1 as createAssociativeArrayKeys, createSet$1 as createAssociativeArraySet, createValue$1 as createAssociativeArrayValue, createValues as createAssociativeArrayValues, createBreadthPathConfig, createChildren, createClamp, 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, 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, createKeypress, createKeyrelease, createKeys, createKonami, createLess, createLessOrEqual, createList, createMap, createMapAsync, createMix, createMousepress, createMouserelease, createNumber, createOmit, createOnlyChild, createOutdegree, createOutgoing, createPick, createReduce, createReduceAsync, createRemove, createReorder, createReplace, createResults, createReverse, createRoot, createSanitize, createSet, createShuffle, createSiblings, createSlice, createSlug, createSome, createSort, createSwap, createTerminal, createTotalSiblings, createTouchpress, createTouchrelease, createFind as createTreeFind, createTry, createTryAsync, createUnique, createValue, 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 };
|
package/lib/index.js
CHANGED
|
@@ -890,10 +890,19 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
890
890
|
toCode,
|
|
891
891
|
toAliases,
|
|
892
892
|
getRequest: () => request
|
|
893
|
-
}), fromComboToAliasesLength = createAliasesLength({ toLonghand })
|
|
894
|
-
|
|
895
|
-
|
|
893
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand }), maybeAddWindowBlurListener = () => {
|
|
894
|
+
if (windowBlurStatus === "added")
|
|
895
|
+
return;
|
|
896
|
+
window.addEventListener("blur", onWindowBlur);
|
|
897
|
+
windowBlurStatus = "added";
|
|
898
|
+
}, onWindowBlur = () => {
|
|
899
|
+
clearStatuses();
|
|
900
|
+
localStatus = "recognizing";
|
|
901
|
+
stop();
|
|
902
|
+
};
|
|
903
|
+
let request, localStatus, windowBlurStatus = "removed";
|
|
896
904
|
const keydown = (event, api) => {
|
|
905
|
+
maybeAddWindowBlurListener();
|
|
897
906
|
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
898
907
|
if (toStatus(key) === "down") {
|
|
899
908
|
onDown?.(toHookApi(api));
|
|
@@ -971,15 +980,17 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
|
|
|
971
980
|
onUp?.(toHookApi(api));
|
|
972
981
|
};
|
|
973
982
|
const visibilitychange = (event, api) => {
|
|
974
|
-
if (document.visibilityState === "hidden")
|
|
975
|
-
|
|
976
|
-
localStatus = "recognizing";
|
|
977
|
-
stop();
|
|
978
|
-
}
|
|
983
|
+
if (document.visibilityState === "hidden")
|
|
984
|
+
onWindowBlur();
|
|
979
985
|
onVisibilitychange?.(toHookApi(api));
|
|
980
986
|
};
|
|
981
987
|
return {
|
|
982
|
-
keydown
|
|
988
|
+
keydown: {
|
|
989
|
+
effect: keydown,
|
|
990
|
+
stop: () => {
|
|
991
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
992
|
+
}
|
|
993
|
+
},
|
|
983
994
|
keyup,
|
|
984
995
|
visibilitychange
|
|
985
996
|
};
|
|
@@ -1032,9 +1043,19 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1032
1043
|
toCode,
|
|
1033
1044
|
toAliases,
|
|
1034
1045
|
getRequest: () => request
|
|
1035
|
-
}), fromComboToAliasesLength = createAliasesLength({ toLonghand })
|
|
1036
|
-
|
|
1046
|
+
}), fromComboToAliasesLength = createAliasesLength({ toLonghand }), maybeAddWindowBlurListener = () => {
|
|
1047
|
+
if (windowBlurStatus === "added")
|
|
1048
|
+
return;
|
|
1049
|
+
window.addEventListener("blur", onWindowBlur);
|
|
1050
|
+
windowBlurStatus = "added";
|
|
1051
|
+
}, onWindowBlur = () => {
|
|
1052
|
+
clearStatuses();
|
|
1053
|
+
localStatus = "recognizing";
|
|
1054
|
+
stop();
|
|
1055
|
+
};
|
|
1056
|
+
let request, localStatus, windowBlurStatus = "removed";
|
|
1037
1057
|
const keydown = (event, api) => {
|
|
1058
|
+
maybeAddWindowBlurListener();
|
|
1038
1059
|
const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
|
|
1039
1060
|
if (toStatus(key) === "down") {
|
|
1040
1061
|
onDown?.(toHookApi(api));
|
|
@@ -1123,7 +1144,12 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
|
|
|
1123
1144
|
onVisibilitychange?.(toHookApi(api));
|
|
1124
1145
|
};
|
|
1125
1146
|
return {
|
|
1126
|
-
keydown
|
|
1147
|
+
keydown: {
|
|
1148
|
+
effect: keydown,
|
|
1149
|
+
stop: () => {
|
|
1150
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1127
1153
|
keyup,
|
|
1128
1154
|
visibilitychange
|
|
1129
1155
|
};
|
|
@@ -1494,9 +1520,9 @@ function createMouserelease(options = {}) {
|
|
|
1494
1520
|
const { getMetadata, recognized, denied } = api, metadata = getMetadata();
|
|
1495
1521
|
if (metadata.duration >= minDuration && metadata.distance.straight.fromStart >= minDistance && metadata.velocity >= minVelocity) {
|
|
1496
1522
|
recognized();
|
|
1497
|
-
|
|
1498
|
-
denied();
|
|
1523
|
+
return;
|
|
1499
1524
|
}
|
|
1525
|
+
denied();
|
|
1500
1526
|
};
|
|
1501
1527
|
return {
|
|
1502
1528
|
mousedown: {
|
|
@@ -2270,6 +2296,26 @@ function createComputedStyle(pseudoElement) {
|
|
|
2270
2296
|
return (element) => getComputedStyle(element, pseudoElement);
|
|
2271
2297
|
}
|
|
2272
2298
|
|
|
2299
|
+
function createTry() {
|
|
2300
|
+
return (fn) => {
|
|
2301
|
+
try {
|
|
2302
|
+
return fn();
|
|
2303
|
+
} catch (error) {
|
|
2304
|
+
return error;
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
function createTryAsync() {
|
|
2310
|
+
return async (fn) => {
|
|
2311
|
+
try {
|
|
2312
|
+
return await fn();
|
|
2313
|
+
} catch (error) {
|
|
2314
|
+
return error;
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2273
2319
|
const defaultOptions$c = {
|
|
2274
2320
|
toCode: (alias) => fromAliasToCode(alias),
|
|
2275
2321
|
toAliases: (descriptor) => fromKeyboardEventDescriptorToAliases(descriptor)
|
|
@@ -2941,12 +2987,12 @@ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recogn
|
|
|
2941
2987
|
}
|
|
2942
2988
|
metadata.times.start = Math.round(event.timeStamp);
|
|
2943
2989
|
metadata.times.end = Math.round(event.timeStamp);
|
|
2944
|
-
let
|
|
2990
|
+
let previousEndTime = metadata.times.start;
|
|
2945
2991
|
const frameEffect = (timestamp) => {
|
|
2946
|
-
|
|
2992
|
+
previousEndTime = metadata.times.end;
|
|
2947
2993
|
metadata.times.end = Math.round(timestamp);
|
|
2948
2994
|
metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
|
|
2949
|
-
const durationFromPrevious = Math.max(0, metadata.times.end -
|
|
2995
|
+
const durationFromPrevious = Math.max(0, metadata.times.end - previousEndTime);
|
|
2950
2996
|
metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious || 0;
|
|
2951
2997
|
const event2 = getSequence().at(-1);
|
|
2952
2998
|
recognize?.(event2, api);
|
|
@@ -2954,7 +3000,7 @@ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recogn
|
|
|
2954
3000
|
effect(event2);
|
|
2955
3001
|
}, storeDuration = () => {
|
|
2956
3002
|
const sequence = api.getSequence();
|
|
2957
|
-
if (!document.
|
|
3003
|
+
if (!document.contains(
|
|
2958
3004
|
at(-1)(sequence).target
|
|
2959
3005
|
))
|
|
2960
3006
|
return;
|
|
@@ -5414,4 +5460,4 @@ class Storeable {
|
|
|
5414
5460
|
}
|
|
5415
5461
|
}
|
|
5416
5462
|
|
|
5417
|
-
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, createOmit, createOnlyChild, createOutdegree, createOutgoing, createPick, 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 };
|
|
5463
|
+
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, createOmit, createOnlyChild, createOutdegree, createOutgoing, createPick, 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, createTry, createTryAsync, 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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baleada/logic",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.13",
|
|
4
4
|
"description": "UI logic for the Baleada toolkit",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"tsc": "tsc --project tsconfig.build.json",
|
|
16
16
|
"rollup": "rollup --config rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.build.json`}' --bundleConfigAsCjs",
|
|
17
17
|
"prepare": "npm run tsc && npm run lint && npm run rollup",
|
|
18
|
-
"test:coverage": "
|
|
18
|
+
"test:coverage": "bun scripts/testCoverage.ts",
|
|
19
19
|
"test:only": "run() { uvu -r esbuild-register tests/$2 $1.test.ts$; }; run",
|
|
20
20
|
"test:node": "npm run test:only . node",
|
|
21
21
|
"test:browser": "npm run test:only . browser",
|