@baleada/logic 0.22.4 → 0.22.5
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 +141 -93
- package/lib/index.d.ts +20 -24
- package/lib/index.js +138 -94
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -158,7 +158,7 @@ type RecognizeableEffectApi<Type extends ListenableSupportedType, Metadata exten
|
|
|
158
158
|
denied: () => void;
|
|
159
159
|
getSequence: () => ListenEffectParam<Type>[];
|
|
160
160
|
onRecognized: (sequenceItem: ListenEffectParam<Type>) => any;
|
|
161
|
-
}
|
|
161
|
+
};
|
|
162
162
|
type RecognizeableStatus = 'recognized' | 'recognizing' | 'denied' | 'ready';
|
|
163
163
|
type RecognizeOptions<Type extends ListenableSupportedType, Metadata extends Record<any, any>> = {
|
|
164
164
|
onRecognized?: (sequenceItem: ListenEffectParam<Type>) => any;
|
|
@@ -180,14 +180,14 @@ declare class Recognizeable<Type extends ListenableSupportedType, Metadata exten
|
|
|
180
180
|
get metadata(): Metadata;
|
|
181
181
|
private computedSequence;
|
|
182
182
|
setSequence(sequence: ListenEffectParam<Type>[]): this;
|
|
183
|
-
recognize(sequenceItem: ListenEffectParam<Type>,
|
|
183
|
+
recognize(sequenceItem: ListenEffectParam<Type>, { onRecognized }?: RecognizeOptions<Type, Metadata>): this;
|
|
184
184
|
private recognizing;
|
|
185
185
|
private toType;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
type ListenableSupportedType = 'recognizeable' | 'intersect' | 'mutate' | 'resize' | 'idle' | 'message' | 'messageerror' | ListenableMediaQuery | keyof Omit<HTMLElementEventMap, 'resize'> | keyof Omit<DocumentEventMap, 'resize'>;
|
|
189
189
|
type ListenableMediaQuery = `(${string})`;
|
|
190
|
-
type
|
|
190
|
+
type ListenableMousecombo = `${string}+${ListenableLeftClick | ListenableRightClick}`;
|
|
191
191
|
type ListenableLeftClick = 'click' | 'dblclick' | `mouse${string}`;
|
|
192
192
|
type ListenableRightClick = 'rightclick' | 'contextmenu';
|
|
193
193
|
type ListenablePointercombo = `${string}+${ListenablePointer}`;
|
|
@@ -197,18 +197,8 @@ type ListenableSupportedEventType = keyof Omit<HTMLElementEventMap, 'resize'> |
|
|
|
197
197
|
type ListenableOptions<Type extends ListenableSupportedType, RecognizeableMetadata extends Record<any, any> = Record<any, any>> = {
|
|
198
198
|
recognizeable?: RecognizeableOptions<Type, RecognizeableMetadata>;
|
|
199
199
|
};
|
|
200
|
-
type ListenEffect<Type extends ListenableSupportedType> = Type extends 'intersect' ? (entries: ListenEffectParam<Type
|
|
200
|
+
type ListenEffect<Type extends ListenableSupportedType> = Type extends 'intersect' ? (entries: ListenEffectParam<Type>) => any : Type extends 'mutate' ? (records: ListenEffectParam<Type>) => any : Type extends 'resize' ? (entries: ListenEffectParam<Type>) => any : Type extends 'idle' ? (deadline: ListenEffectParam<Type>) => any : Type extends ('message' | 'messageerror') ? (event: MessageEvent) => any : Type extends ListenableMediaQuery ? (event: ListenEffectParam<Type>) => any : Type extends (ListenableLeftClick | ListenableRightClick) ? (event: ListenEffectParam<Type>) => any : Type extends (ListenablePointer) ? (event: ListenEffectParam<Type>) => any : Type extends ('keydown' | 'keyup') ? (event: ListenEffectParam<Type>) => any : Type extends keyof Omit<HTMLElementEventMap, 'resize'> ? (event: ListenEffectParam<Type>) => any : Type extends keyof Omit<DocumentEventMap, 'resize'> ? (event: ListenEffectParam<Type>) => any : never;
|
|
201
201
|
type ListenEffectParam<Type extends ListenableSupportedType> = Type extends 'intersect' ? IntersectionObserverEntry[] : Type extends 'mutate' ? MutationRecord[] : Type extends 'resize' ? ResizeObserverEntry[] : Type extends 'idle' ? IdleDeadline : Type extends ListenableMediaQuery ? MediaQueryListEvent : Type extends ListenableRightClick ? MouseEvent : Type extends keyof Omit<HTMLElementEventMap, 'resize'> ? HTMLElementEventMap[Type] : Type extends keyof Omit<DocumentEventMap, 'resize'> ? DocumentEventMap[Type] : never;
|
|
202
|
-
type ListenEffectApi<Type extends ListenableSupportedType> = Type extends 'intersect' ? Record<never, never> : Type extends 'mutate' ? Record<never, never> : Type extends 'resize' ? Record<never, never> : Type extends 'idle' ? Record<never, never> : Type extends ('message' | 'messageerror') ? Record<never, never> : Type extends ListenableMediaQuery ? Record<never, never> : Type extends (ListenableLeftClick | ListenableRightClick) ? MouseEventApi : Type extends (ListenablePointer) ? PointerEventApi : Type extends ('keydown' | 'keyup') ? KeyboardEventApi : Type extends keyof Omit<HTMLElementEventMap, 'resize'> ? Record<never, never> : Type extends keyof Omit<DocumentEventMap, 'resize'> ? Record<never, never> : never;
|
|
203
|
-
type MouseEventApi = {
|
|
204
|
-
matches: (clickcombo: ListenableClickcombo) => boolean;
|
|
205
|
-
};
|
|
206
|
-
type PointerEventApi = {
|
|
207
|
-
matches: (pointercombo: ListenablePointercombo) => boolean;
|
|
208
|
-
};
|
|
209
|
-
type KeyboardEventApi = {
|
|
210
|
-
matches: (keycombo: ListenableKeycombo) => boolean;
|
|
211
|
-
};
|
|
212
202
|
type ListenOptions<Type extends ListenableSupportedType> = Type extends 'intersect' ? {
|
|
213
203
|
observer?: IntersectionObserverInit;
|
|
214
204
|
} & ObservationListenOptions : Type extends 'mutate' ? {
|
|
@@ -320,7 +310,7 @@ declare class Broadcastable<State> {
|
|
|
320
310
|
stop(): this;
|
|
321
311
|
private stopped;
|
|
322
312
|
}
|
|
323
|
-
declare function toMessageListenParams<State>(instance: Broadcastable<State>, effect: (event: MessageEvent<State
|
|
313
|
+
declare function toMessageListenParams<State>(instance: Broadcastable<State>, effect: (event: MessageEvent<State>) => void): Parameters<Listenable<'message'>['listen']>;
|
|
324
314
|
|
|
325
315
|
type CompleteableOptions = {
|
|
326
316
|
segment?: {
|
|
@@ -762,14 +752,14 @@ declare class Storeable<String extends string> {
|
|
|
762
752
|
removeStatus(): this;
|
|
763
753
|
}
|
|
764
754
|
|
|
765
|
-
declare function createReduceAsync<Item, Accumulator>(accumulate: (accumulator
|
|
766
|
-
declare function createReduce<Item, Accumulator>(accumulate: (accumulator
|
|
755
|
+
declare function createReduceAsync<Item, Accumulator>(accumulate: (accumulator: Accumulator, item: Item, index: number) => Promise<Accumulator>, initialValue?: Accumulator): (array: Item[]) => Promise<Accumulator>;
|
|
756
|
+
declare function createReduce<Item, Accumulator>(accumulate: (accumulator: Accumulator, item: Item, index: number) => Accumulator, initialValue?: Accumulator): (array: Item[]) => Accumulator;
|
|
767
757
|
type ArrayFunctionAsync<Item, Returned> = (array: Item[]) => Promise<Returned>;
|
|
768
|
-
declare function createForEachAsync<Item>(forEach: (item
|
|
769
|
-
declare function createMapAsync<Item, Mapped>(transform: (item
|
|
770
|
-
declare function createFilterAsync<Item>(condition: (item
|
|
758
|
+
declare function createForEachAsync<Item>(forEach: (item: Item, index: number) => any): ArrayFunctionAsync<Item, any>;
|
|
759
|
+
declare function createMapAsync<Item, Mapped>(transform: (item: Item, index: number) => Promise<Mapped>): ArrayFunctionAsync<Item, Mapped[]>;
|
|
760
|
+
declare function createFilterAsync<Item>(condition: (item: Item, index: number) => Promise<boolean>): ArrayFunctionAsync<Item, Item[]>;
|
|
771
761
|
type ArrayFunction<Item, Returned> = (array: Item[]) => Returned;
|
|
772
|
-
declare function
|
|
762
|
+
declare function createRemove<Item>(index: number): ArrayFunction<Item, Item[]>;
|
|
773
763
|
declare function createInsert<Item>(item: Item, index: number): ArrayFunction<Item, Item[]>;
|
|
774
764
|
declare function createReorder<Item>(from: {
|
|
775
765
|
start: number;
|
|
@@ -779,8 +769,8 @@ declare function createSwap<Item>(indices: [number, number]): ArrayFunction<Item
|
|
|
779
769
|
declare function createReplace<Item>(index: number, item: Item): ArrayFunction<Item, Item[]>;
|
|
780
770
|
declare function createUnique<Item>(): ArrayFunction<Item, Item[]>;
|
|
781
771
|
declare function createSlice<Item>(from: number, to?: number): ArrayFunction<Item, Item[]>;
|
|
782
|
-
declare function createFilter<Item>(condition: (item
|
|
783
|
-
declare function createMap<Item, Transformed = Item>(transform: (item
|
|
772
|
+
declare function createFilter<Item>(condition: (item: Item, index: number) => boolean): ArrayFunction<Item, Item[]>;
|
|
773
|
+
declare function createMap<Item, Transformed = Item>(transform: (item: Item, index: number) => Transformed): ArrayFunction<Item, Transformed[]>;
|
|
784
774
|
declare function createConcat<Item>(...arrays: Item[][]): ArrayFunction<Item, Item[]>;
|
|
785
775
|
declare function createReverse<Item>(): ArrayFunction<Item, Item[]>;
|
|
786
776
|
declare function createSort<Item>(compare?: (itemA: Item, itemB: Item) => number): ArrayFunction<Item, Item[]>;
|
|
@@ -798,6 +788,12 @@ type MapFunction<Key, Value, Returned> = (transform: Map<Key, Value>) => Returne
|
|
|
798
788
|
declare function createRename<Key, Value>(from: Key, to: Key): MapFunction<Key, Value, Map<Key, Value>>;
|
|
799
789
|
type ObjectFunction<Key extends string | number | symbol, Value, Returned> = (transform: Record<Key, Value>) => Returned;
|
|
800
790
|
declare function createToEntries<Key extends string | number | symbol, Value>(): ObjectFunction<Key, Value, [Key, Value][]>;
|
|
791
|
+
type EventFunction<Evt extends Event, Returned> = (event: Evt) => Returned;
|
|
792
|
+
declare function createMatchesKeycombo(keycombo: string): EventFunction<KeyboardEvent, boolean>;
|
|
793
|
+
declare function createMatchesMousecombo(mousecombo: string): EventFunction<MouseEvent, boolean>;
|
|
794
|
+
declare function createMatchesPointercombo(pointercombo: string): EventFunction<PointerEvent, boolean>;
|
|
795
|
+
type ElementFunction<El extends HTMLElement, Returned> = (element: El) => Returned;
|
|
796
|
+
declare function createToFocusable(order: 'first' | 'last', elementIsCandidate?: boolean): ElementFunction<HTMLElement, HTMLElement | undefined>;
|
|
801
797
|
declare class Pipeable {
|
|
802
798
|
private state;
|
|
803
799
|
constructor(state: any);
|
|
@@ -805,4 +801,4 @@ declare class Pipeable {
|
|
|
805
801
|
pipeAsync(...fns: ((...args: any[]) => Promise<any>)[]): Promise<any>;
|
|
806
802
|
}
|
|
807
803
|
|
|
808
|
-
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, Broadcastable, BroadcastableOptions, BroadcastableStatus, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, Drawable, DrawableOptions, DrawableState, DrawableStatus, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive,
|
|
804
|
+
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, Broadcastable, BroadcastableOptions, BroadcastableStatus, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, Drawable, DrawableOptions, DrawableState, DrawableStatus, ElementFunction, EventFunction, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableKeycombo, ListenableMousecombo, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MapFunction, Navigateable, NavigateableOptions, NavigateableStatus, NumberFunction, ObjectFunction, Pickable, PickableOptions, PickableStatus, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffect, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Shareable, ShareableOptions, ShareableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createMatchesKeycombo, createMatchesMousecombo, createMatchesPointercombo, createReduce, createReduceAsync, createRemove, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createToFocusable, 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 };
|