@opentui/keymap 0.0.0-20260423-76a94f40
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/LICENSE +21 -0
- package/README.md +54 -0
- package/addons/index.js +4390 -0
- package/addons/opentui/index.js +4712 -0
- package/html.js +4151 -0
- package/index.js +3631 -0
- package/opentui.js +3996 -0
- package/package.json +85 -0
- package/react/index.js +151 -0
- package/solid/index.js +119 -0
- package/src/addons/index.d.ts +1 -0
- package/src/addons/opentui/base-layout.d.ts +7 -0
- package/src/addons/opentui/edit-buffer-bindings.d.ts +38 -0
- package/src/addons/opentui/index.d.ts +4 -0
- package/src/addons/universal/aliases.d.ts +7 -0
- package/src/addons/universal/backspace-pops-pending-sequence.d.ts +13 -0
- package/src/addons/universal/comma-bindings.d.ts +6 -0
- package/src/addons/universal/dead-bindings.d.ts +6 -0
- package/src/addons/universal/default-parser.d.ts +16 -0
- package/src/addons/universal/emacs-bindings.d.ts +5 -0
- package/src/addons/universal/enabled.d.ts +16 -0
- package/src/addons/universal/escape-clears-pending-sequence.d.ts +14 -0
- package/src/addons/universal/ex-commands.d.ts +16 -0
- package/src/addons/universal/index.d.ts +21 -0
- package/src/addons/universal/leader.d.ts +9 -0
- package/src/addons/universal/metadata.d.ts +6 -0
- package/src/addons/universal/timed-leader.d.ts +12 -0
- package/src/addons/universal/unresolved-commands.d.ts +6 -0
- package/src/html.d.ts +21 -0
- package/src/index.d.ts +3 -0
- package/src/keymap-benchmark.d.ts +1 -0
- package/src/keymap.d.ts +73 -0
- package/src/lib/emitter.d.ts +13 -0
- package/src/lib/registry.d.ts +28 -0
- package/src/opentui.d.ts +7 -0
- package/src/react/index.d.ts +42 -0
- package/src/schema.d.ts +3 -0
- package/src/services/activation.d.ts +44 -0
- package/src/services/command-catalog.d.ts +49 -0
- package/src/services/command-executor.d.ts +22 -0
- package/src/services/compiler.d.ts +21 -0
- package/src/services/conditions.d.ts +20 -0
- package/src/services/dispatch.d.ts +34 -0
- package/src/services/environment.d.ts +25 -0
- package/src/services/keys.d.ts +18 -0
- package/src/services/layers.d.ts +34 -0
- package/src/services/notify.d.ts +18 -0
- package/src/services/primitives/active-layers.d.ts +5 -0
- package/src/services/primitives/binding-inputs.d.ts +4 -0
- package/src/services/primitives/field-invariants.d.ts +3 -0
- package/src/services/runtime.d.ts +15 -0
- package/src/services/state.d.ts +102 -0
- package/src/services/values.d.ts +7 -0
- package/src/solid/index.d.ts +45 -0
- package/src/types.d.ts +497 -0
package/src/keymap.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ActiveKey, ActiveKeyOptions, BindingInput, BindingExpander, BindingParser, BindingFieldCompiler, Bindings, BindingTransformer, Events, CommandFieldCompiler, CommandEntry, CommandQuery, CommandRecord, KeymapEvent, KeymapHost, LayerAnalyzer, Listener, RunCommandOptions, RunCommandResult, CommandResolver, KeyInterceptOptions, KeyInputContext, Layer, LayerFieldCompiler, RawInterceptOptions, RawInputContext, EventMatchResolver, KeyStringifyInput, KeyToken, KeyLike, KeySequencePart } from "./types.js";
|
|
2
|
+
export declare class Keymap<TTarget extends object, TEvent extends KeymapEvent = KeymapEvent> {
|
|
3
|
+
private readonly host;
|
|
4
|
+
private readonly state;
|
|
5
|
+
private cleanedUp;
|
|
6
|
+
private readonly resources;
|
|
7
|
+
private readonly cleanupListeners;
|
|
8
|
+
private events;
|
|
9
|
+
private hooks;
|
|
10
|
+
private readonly notify;
|
|
11
|
+
private readonly activation;
|
|
12
|
+
private readonly runtime;
|
|
13
|
+
private readonly conditions;
|
|
14
|
+
private readonly catalog;
|
|
15
|
+
private readonly executor;
|
|
16
|
+
private readonly compiler;
|
|
17
|
+
private readonly dispatch;
|
|
18
|
+
private readonly layers;
|
|
19
|
+
private readonly environment;
|
|
20
|
+
private readonly keypressListener;
|
|
21
|
+
private readonly keyreleaseListener;
|
|
22
|
+
private readonly rawListener;
|
|
23
|
+
private readonly focusedTargetListener;
|
|
24
|
+
constructor(host: KeymapHost<TTarget, TEvent>);
|
|
25
|
+
private cleanup;
|
|
26
|
+
setData(name: string, value: unknown): void;
|
|
27
|
+
getData(name: string): unknown;
|
|
28
|
+
hasPendingSequence(): boolean;
|
|
29
|
+
getPendingSequence(): readonly KeySequencePart[];
|
|
30
|
+
createKeyMatcher(key: KeyLike): (input: KeyStringifyInput | null | undefined) => boolean;
|
|
31
|
+
clearPendingSequence(): void;
|
|
32
|
+
popPendingSequence(): boolean;
|
|
33
|
+
getActiveKeys(options?: ActiveKeyOptions): readonly ActiveKey<TTarget, TEvent>[];
|
|
34
|
+
getCommands(query?: CommandQuery<TTarget>): readonly CommandRecord[];
|
|
35
|
+
getCommandEntries(query?: CommandQuery<TTarget>): readonly CommandEntry<TTarget, TEvent>[];
|
|
36
|
+
normalizeCommandName(name: string): string;
|
|
37
|
+
normalizeBindings(bindings: Bindings<TTarget, TEvent>): BindingInput<TTarget, TEvent>[];
|
|
38
|
+
acquireResource(key: symbol, setup: () => () => void): () => void;
|
|
39
|
+
runCommand(cmd: string, options?: RunCommandOptions<TTarget, TEvent>): RunCommandResult;
|
|
40
|
+
on(name: "state", fn: Listener<Events<TTarget, TEvent>["state"]>): () => void;
|
|
41
|
+
on(name: "pendingSequence", fn: Listener<Events<TTarget, TEvent>["pendingSequence"]>): () => void;
|
|
42
|
+
on(name: "warning", fn: Listener<Events<TTarget, TEvent>["warning"]>): () => void;
|
|
43
|
+
on(name: "error", fn: Listener<Events<TTarget, TEvent>["error"]>): () => void;
|
|
44
|
+
intercept(name: "key", fn: (ctx: KeyInputContext<TEvent>) => void, options?: KeyInterceptOptions): () => void;
|
|
45
|
+
intercept(name: "raw", fn: (ctx: RawInputContext) => void, options?: RawInterceptOptions): () => void;
|
|
46
|
+
registerLayer(layer: Layer<TTarget, TEvent>): () => void;
|
|
47
|
+
registerLayerFields(fields: Record<string, LayerFieldCompiler>): () => void;
|
|
48
|
+
prependBindingTransformer(transformer: BindingTransformer<TTarget, TEvent>): () => void;
|
|
49
|
+
appendBindingTransformer(transformer: BindingTransformer<TTarget, TEvent>): () => void;
|
|
50
|
+
clearBindingTransformers(): void;
|
|
51
|
+
prependBindingParser(parser: BindingParser): () => void;
|
|
52
|
+
appendBindingParser(parser: BindingParser): () => void;
|
|
53
|
+
clearBindingParsers(): void;
|
|
54
|
+
registerToken(token: KeyToken): () => void;
|
|
55
|
+
prependBindingExpander(expander: BindingExpander): () => void;
|
|
56
|
+
appendBindingExpander(expander: BindingExpander): () => void;
|
|
57
|
+
clearBindingExpanders(): void;
|
|
58
|
+
registerBindingFields(fields: Record<string, BindingFieldCompiler>): () => void;
|
|
59
|
+
registerCommandFields(fields: Record<string, CommandFieldCompiler>): () => void;
|
|
60
|
+
prependCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
61
|
+
appendCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
62
|
+
clearCommandResolvers(): void;
|
|
63
|
+
prependLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
64
|
+
appendLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
65
|
+
clearLayerAnalyzers(): void;
|
|
66
|
+
prependEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
67
|
+
appendEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
68
|
+
clearEventMatchResolvers(): void;
|
|
69
|
+
private handleFocusedTargetChange;
|
|
70
|
+
private warnUnknownField;
|
|
71
|
+
private warnUnknownToken;
|
|
72
|
+
private releaseResource;
|
|
73
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type EmitterListener<TValue> = [TValue] extends [void] ? () => void : (value: TValue) => void;
|
|
2
|
+
type EmitterArgs<TValue> = [TValue] extends [void] ? [] : [TValue];
|
|
3
|
+
export declare class Emitter<TEvents extends Record<string, unknown>> {
|
|
4
|
+
private readonly onError;
|
|
5
|
+
private listeners;
|
|
6
|
+
constructor(onError: (name: keyof TEvents, error: unknown) => void);
|
|
7
|
+
hook<TName extends keyof TEvents>(name: TName, listener: EmitterListener<TEvents[TName]>): () => void;
|
|
8
|
+
has<TName extends keyof TEvents>(name: TName): boolean;
|
|
9
|
+
off<TName extends keyof TEvents>(name: TName, listener: EmitterListener<TEvents[TName]>): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
emit<TName extends keyof TEvents>(name: TName, ...args: EmitterArgs<TEvents[TName]>): void;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type PriorityRegistration<TListener, TOptions extends {
|
|
2
|
+
priority: number;
|
|
3
|
+
}> = Readonly<TOptions & {
|
|
4
|
+
listener: TListener;
|
|
5
|
+
order: number;
|
|
6
|
+
}>;
|
|
7
|
+
declare abstract class CopyOnWriteRegistry<TValue> {
|
|
8
|
+
private items;
|
|
9
|
+
protected getItems(): readonly TValue[];
|
|
10
|
+
protected setItems(items: readonly TValue[]): void;
|
|
11
|
+
protected removeItem(value: TValue): boolean;
|
|
12
|
+
has(): boolean;
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class OrderedRegistry<TValue> extends CopyOnWriteRegistry<TValue> {
|
|
16
|
+
append(value: TValue): () => void;
|
|
17
|
+
prepend(value: TValue): () => void;
|
|
18
|
+
remove(value: TValue): boolean;
|
|
19
|
+
values(): readonly TValue[];
|
|
20
|
+
}
|
|
21
|
+
export declare class PriorityRegistry<TListener, TOptions extends {
|
|
22
|
+
priority: number;
|
|
23
|
+
}> extends CopyOnWriteRegistry<PriorityRegistration<TListener, TOptions>> {
|
|
24
|
+
private order;
|
|
25
|
+
register(listener: TListener, options: TOptions): () => void;
|
|
26
|
+
entries(): readonly PriorityRegistration<TListener, TOptions>[];
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/src/opentui.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { KeyEvent, type CliRenderer, type Renderable } from "@opentui/core";
|
|
2
|
+
import { Keymap } from "./keymap.js";
|
|
3
|
+
import type { KeymapHost } from "./types.js";
|
|
4
|
+
export * from "./index.js";
|
|
5
|
+
export declare function createOpenTuiKeymapHost(renderer: CliRenderer): KeymapHost<Renderable, KeyEvent>;
|
|
6
|
+
export declare function createOpenTuiKeymap(renderer: CliRenderer): Keymap<Renderable, KeyEvent>;
|
|
7
|
+
export declare function createDefaultOpenTuiKeymap(renderer: CliRenderer): Keymap<Renderable, KeyEvent>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { KeyEvent, Renderable } from "@opentui/core";
|
|
2
|
+
import { type ActiveKey, type ActiveKeyOptions, type LayerFields, type Keymap, type ReactiveMatcher, type KeySequencePart } from "../index.js";
|
|
3
|
+
import { type DependencyList, type ReactNode } from "react";
|
|
4
|
+
type OpenTuiKeymap = Keymap<Renderable, KeyEvent>;
|
|
5
|
+
export interface KeymapProviderProps {
|
|
6
|
+
keymap: OpenTuiKeymap;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function KeymapProvider({ keymap, children }: KeymapProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<OpenTuiKeymap | null>>;
|
|
10
|
+
export type UseBindingsTarget<TRenderable extends Renderable = Renderable> = TRenderable | null | undefined | (() => TRenderable | null | undefined);
|
|
11
|
+
type UseBindingsLayerBase = LayerFields<Renderable, KeyEvent>;
|
|
12
|
+
export type BindingsRef<TRenderable extends Renderable = Renderable> = (value: TRenderable | null) => void;
|
|
13
|
+
export interface UseGlobalBindingsLayer extends UseBindingsLayerBase {
|
|
14
|
+
scope?: "global";
|
|
15
|
+
target?: undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface UseFocusBindingsLayer<TRenderable extends Renderable = Renderable> extends UseBindingsLayerBase {
|
|
18
|
+
scope: "focus";
|
|
19
|
+
target?: UseBindingsTarget<TRenderable>;
|
|
20
|
+
}
|
|
21
|
+
export interface UseFocusWithinBindingsLayer<TRenderable extends Renderable = Renderable> extends UseBindingsLayerBase {
|
|
22
|
+
scope: "focus-within";
|
|
23
|
+
target?: UseBindingsTarget<TRenderable>;
|
|
24
|
+
}
|
|
25
|
+
export interface UseInferredFocusWithinBindingsLayer<TRenderable extends Renderable = Renderable> extends UseBindingsLayerBase {
|
|
26
|
+
scope?: undefined;
|
|
27
|
+
target: UseBindingsTarget<TRenderable>;
|
|
28
|
+
}
|
|
29
|
+
export type UseTargetBindingsLayer<TRenderable extends Renderable = Renderable> = UseFocusBindingsLayer<TRenderable> | UseFocusWithinBindingsLayer<TRenderable> | UseInferredFocusWithinBindingsLayer<TRenderable>;
|
|
30
|
+
export type UseBindingsLayer<TRenderable extends Renderable = Renderable> = UseGlobalBindingsLayer | UseTargetBindingsLayer<TRenderable>;
|
|
31
|
+
export declare const useKeymap: () => OpenTuiKeymap;
|
|
32
|
+
export declare const useActiveKeys: (options?: ActiveKeyOptions) => readonly ActiveKey[];
|
|
33
|
+
export declare const usePendingSequence: () => readonly KeySequencePart[];
|
|
34
|
+
export declare function useBindings<TRenderable extends Renderable = Renderable>(createLayer: () => UseGlobalBindingsLayer, deps?: DependencyList): BindingsRef<TRenderable>;
|
|
35
|
+
export declare function useBindings<TRenderable extends Renderable = Renderable>(createLayer: () => UseTargetBindingsLayer<TRenderable>, deps?: DependencyList): BindingsRef<TRenderable>;
|
|
36
|
+
/**
|
|
37
|
+
* Adapts any `subscribe` + `getSnapshot` store to
|
|
38
|
+
* `ReactiveMatcher`. Pass `predicate` when the snapshot value is not
|
|
39
|
+
* already boolean.
|
|
40
|
+
*/
|
|
41
|
+
export declare function reactiveMatcherFromStore<T>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T, predicate?: (value: T) => boolean): ReactiveMatcher;
|
|
42
|
+
export {};
|
package/src/schema.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Emitter } from "../lib/emitter.js";
|
|
2
|
+
import type { ActiveKey, ActiveKeyOptions, Hooks, KeymapEvent, KeymapHost, KeySequencePart, PendingSequenceState, RegisteredLayer, SequenceNode } from "../types.js";
|
|
3
|
+
import type { CommandCatalogService } from "./command-catalog.js";
|
|
4
|
+
import type { ConditionService } from "./conditions.js";
|
|
5
|
+
import type { NotificationService } from "./notify.js";
|
|
6
|
+
import type { State } from "./state.js";
|
|
7
|
+
export declare class ActivationService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
8
|
+
private readonly state;
|
|
9
|
+
private readonly host;
|
|
10
|
+
private readonly hooks;
|
|
11
|
+
private readonly notify;
|
|
12
|
+
private readonly conditions;
|
|
13
|
+
private readonly catalog;
|
|
14
|
+
constructor(state: State<TTarget, TEvent>, host: KeymapHost<TTarget, TEvent>, hooks: Emitter<Hooks<TTarget, TEvent>>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, catalog: CommandCatalogService<TTarget, TEvent>);
|
|
15
|
+
getFocusedTarget(): TTarget | null;
|
|
16
|
+
getFocusedTargetIfAvailable(): TTarget | null;
|
|
17
|
+
setPendingSequence(next: PendingSequenceState<TTarget, TEvent> | null): void;
|
|
18
|
+
ensureValidPendingSequence(): PendingSequenceState<TTarget, TEvent> | undefined;
|
|
19
|
+
getPendingSequence(): readonly KeySequencePart[];
|
|
20
|
+
popPendingSequence(): boolean;
|
|
21
|
+
getActiveKeys(options?: ActiveKeyOptions): readonly ActiveKey<TTarget, TEvent>[];
|
|
22
|
+
nodeHasReachableBindings(node: SequenceNode<TTarget, TEvent>, focused: TTarget | null): boolean;
|
|
23
|
+
getActiveLayers(focused: TTarget | null): RegisteredLayer<TTarget, TEvent>[];
|
|
24
|
+
isLayerActiveForFocused(layer: RegisteredLayer<TTarget, TEvent>, focused: TTarget | null): boolean;
|
|
25
|
+
layerCanCacheActiveKeys(layer: RegisteredLayer<TTarget, TEvent>): boolean;
|
|
26
|
+
activeLayersCanCacheActiveKeys(activeLayers: readonly RegisteredLayer<TTarget, TEvent>[]): boolean;
|
|
27
|
+
private collectSequencePartsFromNode;
|
|
28
|
+
private getMatchingBindings;
|
|
29
|
+
private hasMatchingBindings;
|
|
30
|
+
private getNodePresentation;
|
|
31
|
+
private toActiveBinding;
|
|
32
|
+
private collectActiveBindings;
|
|
33
|
+
private collectActiveKeysAtRoot;
|
|
34
|
+
private collectActiveKeysFromChildren;
|
|
35
|
+
private selectActiveKey;
|
|
36
|
+
private selectPrefixActiveKey;
|
|
37
|
+
private selectExactActiveKey;
|
|
38
|
+
private selectActiveBindings;
|
|
39
|
+
private createActiveKeyState;
|
|
40
|
+
private updateActiveKeyState;
|
|
41
|
+
private materializeActiveKey;
|
|
42
|
+
private invalidateCaches;
|
|
43
|
+
private notifyPendingSequenceChange;
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Attributes, BindingCommand, CommandEntry, CommandDefinition, CommandResolutionStatus, CommandQuery, CommandRecord, CommandResolver, CompiledBinding, KeymapEvent, KeymapHost, RegisteredCommand, ResolvedBindingCommand } from "../types.js";
|
|
2
|
+
import type { ConditionService } from "./conditions.js";
|
|
3
|
+
import type { NotificationService } from "./notify.js";
|
|
4
|
+
import type { ActiveCommandView, ResolvedCommandEntry, State } from "./state.js";
|
|
5
|
+
interface CommandCatalogOptions {
|
|
6
|
+
onCommandResolversChanged(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function normalizeBindingCommand<TTarget extends object, TEvent extends KeymapEvent>(command: BindingCommand<TTarget, TEvent> | undefined): BindingCommand<TTarget, TEvent> | undefined;
|
|
9
|
+
export declare function normalizeCommandName(name: string): string;
|
|
10
|
+
export declare class CommandCatalogService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
11
|
+
private readonly state;
|
|
12
|
+
private readonly host;
|
|
13
|
+
private readonly notify;
|
|
14
|
+
private readonly conditions;
|
|
15
|
+
private readonly options;
|
|
16
|
+
constructor(state: State<TTarget, TEvent>, host: KeymapHost<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, options: CommandCatalogOptions);
|
|
17
|
+
normalizeCommands(commands: readonly CommandDefinition<TTarget, TEvent>[]): RegisteredCommand<TTarget, TEvent>[];
|
|
18
|
+
prependCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
19
|
+
appendCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
20
|
+
clearCommandResolvers(): void;
|
|
21
|
+
getCommands(query?: CommandQuery<TTarget>): readonly CommandRecord[];
|
|
22
|
+
getCommandEntries(query?: CommandQuery<TTarget>): readonly CommandEntry<TTarget, TEvent>[];
|
|
23
|
+
getResolvedCommandChain(command: string, focused: TTarget | null, includeRecord: boolean): {
|
|
24
|
+
entries?: readonly ResolvedCommandEntry<TTarget, TEvent>[];
|
|
25
|
+
hadError: boolean;
|
|
26
|
+
};
|
|
27
|
+
getCommandAttrs(command: string, focused: TTarget | null): Readonly<Attributes> | undefined;
|
|
28
|
+
getTopCommandRecord(command: string, focused: TTarget | null): CommandRecord | undefined;
|
|
29
|
+
getActiveCommandView(focused: TTarget | null): ActiveCommandView<TTarget, TEvent>;
|
|
30
|
+
isBindingVisible(binding: CompiledBinding<TTarget, TEvent>, focused: TTarget | null, activeView: ActiveCommandView<TTarget, TEvent>): boolean;
|
|
31
|
+
getBindingCommandAttrs(binding: CompiledBinding<TTarget, TEvent>, focused: TTarget | null, activeView: ActiveCommandView<TTarget, TEvent>): Readonly<Attributes> | undefined;
|
|
32
|
+
getCommandResolutionStatus(command: string, layerCommands?: ReadonlyMap<string, RegisteredCommand<TTarget, TEvent>>): CommandResolutionStatus;
|
|
33
|
+
private mutateCommandResolvers;
|
|
34
|
+
private getTopResolvedCommand;
|
|
35
|
+
private getFallbackResolvedCommand;
|
|
36
|
+
private getResolvedCommandChainFromView;
|
|
37
|
+
private getRegisteredLayerCommandEntries;
|
|
38
|
+
private getCommandQueryContext;
|
|
39
|
+
private getFilteredCommandEntries;
|
|
40
|
+
private collectCommandEntryBindings;
|
|
41
|
+
private collectBindingForCommandEntries;
|
|
42
|
+
private resolveCommandWithResolvers;
|
|
43
|
+
private createCommandResolverContext;
|
|
44
|
+
}
|
|
45
|
+
export declare function getRegisteredCommandRecord<TTarget extends object, TEvent extends KeymapEvent>(command: RegisteredCommand<TTarget, TEvent>): CommandRecord;
|
|
46
|
+
export declare function resolveRegisteredCommand<TTarget extends object, TEvent extends KeymapEvent>(command: RegisteredCommand<TTarget, TEvent>, options?: {
|
|
47
|
+
includeRecord?: boolean;
|
|
48
|
+
}): ResolvedBindingCommand<TTarget, TEvent>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Keymap } from "../keymap.js";
|
|
2
|
+
import type { CompiledBinding, KeymapEvent, RegisteredLayer, RunCommandOptions, RunCommandResult } from "../types.js";
|
|
3
|
+
import { type CommandCatalogService } from "./command-catalog.js";
|
|
4
|
+
import type { ActivationService } from "./activation.js";
|
|
5
|
+
import type { NotificationService } from "./notify.js";
|
|
6
|
+
import type { RuntimeService } from "./runtime.js";
|
|
7
|
+
interface CommandExecutorOptions<TTarget extends object, TEvent extends KeymapEvent> {
|
|
8
|
+
keymap: Keymap<TTarget, TEvent>;
|
|
9
|
+
createCommandEvent: () => TEvent;
|
|
10
|
+
}
|
|
11
|
+
export declare class CommandExecutorService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
12
|
+
private readonly notify;
|
|
13
|
+
private readonly runtime;
|
|
14
|
+
private readonly activation;
|
|
15
|
+
private readonly catalog;
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(notify: NotificationService<TTarget, TEvent>, runtime: RuntimeService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>, catalog: CommandCatalogService<TTarget, TEvent>, options: CommandExecutorOptions<TTarget, TEvent>);
|
|
18
|
+
runCommand(cmd: string, options?: RunCommandOptions<TTarget, TEvent>): RunCommandResult;
|
|
19
|
+
runBinding(bindingLayer: RegisteredLayer<TTarget, TEvent>, binding: CompiledBinding<TTarget, TEvent>, event: TEvent, focused: TTarget | null): boolean;
|
|
20
|
+
private executeResolvedCommand;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConditionService } from "./conditions.js";
|
|
2
|
+
import type { State } from "./state.js";
|
|
3
|
+
import type { NotificationService } from "./notify.js";
|
|
4
|
+
import type { BindingInput, Scope, CompiledBindingsResult, KeyLike, KeymapEvent, KeySequencePart, ResolvedKeyToken } from "../types.js";
|
|
5
|
+
export interface CompilerOptions {
|
|
6
|
+
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
7
|
+
warnUnknownToken: (token: string, sequence: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class CompilerService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
10
|
+
private readonly state;
|
|
11
|
+
private readonly notify;
|
|
12
|
+
private readonly conditions;
|
|
13
|
+
private readonly options;
|
|
14
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, options: CompilerOptions);
|
|
15
|
+
parseTokenKey(key: KeyLike): KeySequencePart;
|
|
16
|
+
compileBindings(bindings: readonly BindingInput<TTarget, TEvent>[], tokens: ReadonlyMap<string, ResolvedKeyToken>, sourceScope: Scope, sourceTarget: TTarget | undefined, sourceLayerOrder: number, compileFields?: Readonly<Record<string, unknown>>): CompiledBindingsResult<TTarget, TEvent>;
|
|
17
|
+
private parseObjectKeyPart;
|
|
18
|
+
private normalizeBindingEvent;
|
|
19
|
+
private applyBindingTransformers;
|
|
20
|
+
private insertBinding;
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NotificationService } from "./notify.js";
|
|
2
|
+
import type { State } from "./state.js";
|
|
3
|
+
import type { KeymapEvent, ReactiveMatcher, RegisteredLayer, RuntimeMatchable, RuntimeMatcher } from "../types.js";
|
|
4
|
+
export declare class ConditionService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
5
|
+
private readonly state;
|
|
6
|
+
private readonly notify;
|
|
7
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>);
|
|
8
|
+
buildRuntimeMatcher(matcher: (() => boolean) | ReactiveMatcher, source: string): RuntimeMatcher;
|
|
9
|
+
hasNoConditions(target: RuntimeMatchable): boolean;
|
|
10
|
+
registerRuntimeMatchable(target: RuntimeMatchable): void;
|
|
11
|
+
unregisterRuntimeMatchable(target: RuntimeMatchable): void;
|
|
12
|
+
invalidateRuntimeConditionKey(name: string): void;
|
|
13
|
+
matchesConditions(target: RuntimeMatchable): boolean;
|
|
14
|
+
layerMatchesRuntimeState(layer: RegisteredLayer<TTarget, TEvent>): boolean;
|
|
15
|
+
private matchRequirements;
|
|
16
|
+
private hasFreshConditionCache;
|
|
17
|
+
private updateConditionCache;
|
|
18
|
+
private matchesRuntimeMatcher;
|
|
19
|
+
private matchesRuntimeMatchers;
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CompilerService } from "./compiler.js";
|
|
2
|
+
import type { ActivationService } from "./activation.js";
|
|
3
|
+
import type { CommandExecutorService } from "./command-executor.js";
|
|
4
|
+
import type { ConditionService } from "./conditions.js";
|
|
5
|
+
import type { NotificationService } from "./notify.js";
|
|
6
|
+
import type { RuntimeService } from "./runtime.js";
|
|
7
|
+
import type { State } from "./state.js";
|
|
8
|
+
import type { EventMatchResolver, KeyInterceptOptions, KeyInputContext, KeymapEvent, RawInterceptOptions, RawInputContext } from "../types.js";
|
|
9
|
+
export declare class DispatchService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
10
|
+
private readonly state;
|
|
11
|
+
private readonly notify;
|
|
12
|
+
private readonly runtime;
|
|
13
|
+
private readonly activation;
|
|
14
|
+
private readonly conditions;
|
|
15
|
+
private readonly executor;
|
|
16
|
+
private readonly compiler;
|
|
17
|
+
private readonly eventMatchResolverContext;
|
|
18
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, runtime: RuntimeService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, executor: CommandExecutorService<TTarget, TEvent>, compiler: CompilerService<TTarget, TEvent>);
|
|
19
|
+
intercept(name: "key", fn: (ctx: KeyInputContext<TEvent>) => void, options?: KeyInterceptOptions): () => void;
|
|
20
|
+
intercept(name: "raw", fn: (ctx: RawInputContext) => void, options?: RawInterceptOptions): () => void;
|
|
21
|
+
prependEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
22
|
+
appendEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
23
|
+
clearEventMatchResolvers(): void;
|
|
24
|
+
handleRawSequence(sequence: string): boolean;
|
|
25
|
+
handleKeyEvent(event: TEvent, release: boolean): void;
|
|
26
|
+
private dispatchReleaseLayers;
|
|
27
|
+
private dispatchLayers;
|
|
28
|
+
private dispatchPendingSequence;
|
|
29
|
+
private dispatchFromRoot;
|
|
30
|
+
private resolveEventMatchKeys;
|
|
31
|
+
private runReleaseBindings;
|
|
32
|
+
private getReachableChild;
|
|
33
|
+
private runBindings;
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CompilerService } from "./compiler.js";
|
|
2
|
+
import type { LayerService } from "./layers.js";
|
|
3
|
+
import type { NotificationService } from "./notify.js";
|
|
4
|
+
import type { State } from "./state.js";
|
|
5
|
+
import type { BindingExpander, BindingFieldCompiler, BindingParser, BindingTransformer, CommandFieldCompiler, KeyToken, KeymapEvent, LayerFieldCompiler } from "../types.js";
|
|
6
|
+
export declare class EnvironmentService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
7
|
+
private readonly state;
|
|
8
|
+
private readonly notify;
|
|
9
|
+
private readonly compiler;
|
|
10
|
+
private readonly layers;
|
|
11
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, compiler: CompilerService<TTarget, TEvent>, layers: LayerService<TTarget, TEvent>);
|
|
12
|
+
prependBindingTransformer(transformer: BindingTransformer<TTarget, TEvent>): () => void;
|
|
13
|
+
appendBindingTransformer(transformer: BindingTransformer<TTarget, TEvent>): () => void;
|
|
14
|
+
clearBindingTransformers(): void;
|
|
15
|
+
prependBindingParser(parser: BindingParser): () => void;
|
|
16
|
+
appendBindingParser(parser: BindingParser): () => void;
|
|
17
|
+
clearBindingParsers(): void;
|
|
18
|
+
registerToken(token: KeyToken): () => void;
|
|
19
|
+
prependBindingExpander(expander: BindingExpander): () => void;
|
|
20
|
+
appendBindingExpander(expander: BindingExpander): () => void;
|
|
21
|
+
clearBindingExpanders(): void;
|
|
22
|
+
registerLayerFields(fields: Record<string, LayerFieldCompiler>): () => void;
|
|
23
|
+
registerBindingFields(fields: Record<string, BindingFieldCompiler>): () => void;
|
|
24
|
+
registerCommandFields(fields: Record<string, CommandFieldCompiler>): () => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { KeyMatch, KeySequencePart, KeyStrokeInput, KeyStringifyInput, KeymapEvent, NormalizedKeyStroke, StringifyOptions } from "../types.js";
|
|
2
|
+
export declare function normalizeBindingTokenName(token: string): string;
|
|
3
|
+
export declare function normalizeKeyName(name: string): string;
|
|
4
|
+
export declare function normalizeKeyStroke(input: KeyStrokeInput): NormalizedKeyStroke;
|
|
5
|
+
export declare function normalizeEventKeyStroke(event: KeymapEvent): NormalizedKeyStroke;
|
|
6
|
+
export declare function cloneKeyStroke(stroke: NormalizedKeyStroke): NormalizedKeyStroke;
|
|
7
|
+
export declare function createKeySequencePart(input: KeyStrokeInput, options?: {
|
|
8
|
+
display?: string;
|
|
9
|
+
match?: KeyMatch;
|
|
10
|
+
tokenName?: string;
|
|
11
|
+
}): KeySequencePart;
|
|
12
|
+
export declare function cloneKeySequencePart(part: KeySequencePart): KeySequencePart;
|
|
13
|
+
export declare function cloneKeySequence(parts: readonly KeySequencePart[]): KeySequencePart[];
|
|
14
|
+
export declare function resolveKeyMatch(input: KeyStringifyInput): KeyMatch;
|
|
15
|
+
export declare function createKeyMatch(input: KeyStrokeInput): KeyMatch;
|
|
16
|
+
export declare function createTextKeyMatch(id: string): KeyMatch;
|
|
17
|
+
export declare function stringifyKeyStroke(input: KeyStringifyInput, options?: StringifyOptions): string;
|
|
18
|
+
export declare function stringifyKeySequence(input: readonly KeyStringifyInput[], options?: StringifyOptions): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CompilerService } from "./compiler.js";
|
|
2
|
+
import type { CommandCatalogService } from "./command-catalog.js";
|
|
3
|
+
import type { ConditionService } from "./conditions.js";
|
|
4
|
+
import type { ActivationService } from "./activation.js";
|
|
5
|
+
import type { KeymapEvent, KeymapHost, Layer, LayerAnalyzer, ResolvedKeyToken } from "../types.js";
|
|
6
|
+
import type { State } from "./state.js";
|
|
7
|
+
import type { NotificationService } from "./notify.js";
|
|
8
|
+
interface LayersOptions<TTarget extends object, TEvent extends KeymapEvent> {
|
|
9
|
+
compiler: CompilerService<TTarget, TEvent>;
|
|
10
|
+
commands: CommandCatalogService<TTarget, TEvent>;
|
|
11
|
+
host: KeymapHost<TTarget, TEvent>;
|
|
12
|
+
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class LayerService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
15
|
+
private readonly state;
|
|
16
|
+
private readonly notify;
|
|
17
|
+
private readonly conditions;
|
|
18
|
+
private readonly activation;
|
|
19
|
+
private readonly options;
|
|
20
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>, options: LayersOptions<TTarget, TEvent>);
|
|
21
|
+
registerLayer(layer: Layer<TTarget, TEvent>): () => void;
|
|
22
|
+
applyTokenState(nextTokens: Map<string, ResolvedKeyToken>): void;
|
|
23
|
+
prependLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
24
|
+
appendLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
25
|
+
clearLayerAnalyzers(): void;
|
|
26
|
+
private normalizeScope;
|
|
27
|
+
private runLayerAnalyzers;
|
|
28
|
+
private compileLayerRuntimeState;
|
|
29
|
+
private getOrCreateTargetBucket;
|
|
30
|
+
private indexLayer;
|
|
31
|
+
private removeLayerFromIndex;
|
|
32
|
+
private unregisterLayer;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Events, HookName, Hooks, KeymapEvent } from "../types.js";
|
|
2
|
+
import type { State } from "./state.js";
|
|
3
|
+
import { Emitter } from "../lib/emitter.js";
|
|
4
|
+
type DiagnosticEvents<TTarget extends object, TEvent extends KeymapEvent> = Pick<Events<TTarget, TEvent>, "warning" | "error">;
|
|
5
|
+
export declare class NotificationService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
6
|
+
private readonly state;
|
|
7
|
+
private readonly events;
|
|
8
|
+
private readonly hooks;
|
|
9
|
+
constructor(state: State<TTarget, TEvent>, events: Emitter<DiagnosticEvents<TTarget, TEvent>>, hooks: Emitter<Hooks<TTarget, TEvent>>);
|
|
10
|
+
runWithStateChangeBatch<T>(fn: () => T): T;
|
|
11
|
+
queueStateChange(): void;
|
|
12
|
+
emitWarning(code: string, warning: unknown, message: string): void;
|
|
13
|
+
emitError(code: string, error: unknown, message: string): void;
|
|
14
|
+
reportListenerError(name: HookName, error: unknown): void;
|
|
15
|
+
warnOnce(key: string, code: string, warning: unknown, message: string): void;
|
|
16
|
+
private flushStateChange;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeymapEvent, KeymapHost, RegisteredLayer, RegisteredLayerBucket } from "../../types.js";
|
|
2
|
+
export declare function getFocusedTargetIfAvailable<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>): TTarget | null;
|
|
3
|
+
export declare function forEachActivationTarget<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>, focused: TTarget | null, visit: (target: TTarget, isFocusedTarget: boolean) => boolean | void): void;
|
|
4
|
+
export declare function getActiveLayersForFocused<TTarget extends object, TEvent extends KeymapEvent>(targetLayers: WeakMap<TTarget, RegisteredLayerBucket<TTarget, TEvent>>, host: KeymapHost<TTarget, TEvent>, focused: TTarget | null): RegisteredLayer<TTarget, TEvent>[];
|
|
5
|
+
export declare function isLayerActiveForFocused<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>, layer: RegisteredLayer<TTarget, TEvent>, focused: TTarget | null): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BindingInput, Bindings, KeymapEvent, ParsedBindingInput } from "../../types.js";
|
|
2
|
+
export declare function normalizeBindingInputs<TTarget extends object, TEvent extends KeymapEvent>(bindings: Bindings<TTarget, TEvent>): BindingInput<TTarget, TEvent>[];
|
|
3
|
+
export declare function snapshotBindingInputs<TTarget extends object, TEvent extends KeymapEvent>(bindings: Bindings<TTarget, TEvent>): BindingInput<TTarget, TEvent>[];
|
|
4
|
+
export declare function snapshotParsedBindingInput<TTarget extends object, TEvent extends KeymapEvent>(binding: ParsedBindingInput<TTarget, TEvent>): ParsedBindingInput<TTarget, TEvent>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Attributes, EventData } from "../../types.js";
|
|
2
|
+
export declare function mergeRequirement(target: EventData, name: string, value: unknown, source: string): void;
|
|
3
|
+
export declare function mergeAttribute(target: Attributes, name: string, value: unknown, source: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventData, KeymapEvent } from "../types.js";
|
|
2
|
+
import type { ActivationService } from "./activation.js";
|
|
3
|
+
import type { ConditionService } from "./conditions.js";
|
|
4
|
+
import type { NotificationService } from "./notify.js";
|
|
5
|
+
import type { State } from "./state.js";
|
|
6
|
+
export declare class RuntimeService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
7
|
+
private readonly state;
|
|
8
|
+
private readonly notify;
|
|
9
|
+
private readonly conditions;
|
|
10
|
+
private readonly activation;
|
|
11
|
+
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>);
|
|
12
|
+
getData(name: string): unknown;
|
|
13
|
+
setData(name: string, value: unknown): void;
|
|
14
|
+
getReadonlyData(): Readonly<EventData>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ActiveKey, BindingExpander, BindingFieldCompiler, BindingParser, BindingTransformer, CommandFieldCompiler, CommandResolver, EventData, EventMatchResolver, KeyInputContext, KeySequencePart, KeymapEvent, LayerAnalyzer, LayerFieldCompiler, PendingSequenceState, RawInputContext, RegisteredCommand, RegisteredLayer, RegisteredLayerBucket, ResolvedBindingCommand, RuntimeMatchable } from "../types.js";
|
|
2
|
+
import { OrderedRegistry, PriorityRegistry } from "../lib/registry.js";
|
|
3
|
+
export interface CoreState {
|
|
4
|
+
order: number;
|
|
5
|
+
}
|
|
6
|
+
export interface EnvironmentState<TTarget extends object, TEvent extends KeymapEvent> {
|
|
7
|
+
tokens: Map<string, import("../types.js").ResolvedKeyToken>;
|
|
8
|
+
layerFields: Map<string, LayerFieldCompiler>;
|
|
9
|
+
bindingExpanders: OrderedRegistry<BindingExpander>;
|
|
10
|
+
bindingParsers: OrderedRegistry<BindingParser>;
|
|
11
|
+
bindingTransformers: OrderedRegistry<BindingTransformer<TTarget, TEvent>>;
|
|
12
|
+
bindingFields: Map<string, BindingFieldCompiler>;
|
|
13
|
+
commandFields: Map<string, CommandFieldCompiler>;
|
|
14
|
+
}
|
|
15
|
+
export interface DispatchState<TEvent extends KeymapEvent> {
|
|
16
|
+
eventMatchResolvers: OrderedRegistry<EventMatchResolver<TEvent>>;
|
|
17
|
+
keyHooks: PriorityRegistry<(ctx: KeyInputContext<TEvent>) => void, {
|
|
18
|
+
priority: number;
|
|
19
|
+
release: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
rawHooks: PriorityRegistry<(ctx: RawInputContext) => void, {
|
|
22
|
+
priority: number;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface LayersState<TTarget extends object, TEvent extends KeymapEvent> {
|
|
26
|
+
layers: Set<RegisteredLayer<TTarget, TEvent>>;
|
|
27
|
+
targetLayers: WeakMap<TTarget, RegisteredLayerBucket<TTarget, TEvent>>;
|
|
28
|
+
layersWithConditions: number;
|
|
29
|
+
layersWithCommands: number;
|
|
30
|
+
layerAnalyzers: OrderedRegistry<LayerAnalyzer<TTarget, TEvent>>;
|
|
31
|
+
}
|
|
32
|
+
export interface LayerCommandEntry<TTarget extends object, TEvent extends KeymapEvent> {
|
|
33
|
+
layer: RegisteredLayer<TTarget, TEvent>;
|
|
34
|
+
command: RegisteredCommand<TTarget, TEvent>;
|
|
35
|
+
}
|
|
36
|
+
export interface ResolvedCommandEntry<TTarget extends object, TEvent extends KeymapEvent> {
|
|
37
|
+
target?: TTarget;
|
|
38
|
+
resolved: ResolvedBindingCommand<TTarget, TEvent>;
|
|
39
|
+
}
|
|
40
|
+
export interface ActiveCommandView<TTarget extends object, TEvent extends KeymapEvent> {
|
|
41
|
+
cacheable: boolean;
|
|
42
|
+
entries: readonly LayerCommandEntry<TTarget, TEvent>[];
|
|
43
|
+
reachable: readonly LayerCommandEntry<TTarget, TEvent>[];
|
|
44
|
+
reachableByName: ReadonlyMap<string, LayerCommandEntry<TTarget, TEvent>>;
|
|
45
|
+
chainsByName: ReadonlyMap<string, readonly LayerCommandEntry<TTarget, TEvent>[]>;
|
|
46
|
+
resolvedWithoutRecordChains: Map<string, readonly ResolvedCommandEntry<TTarget, TEvent>[]>;
|
|
47
|
+
resolvedWithRecordChains: Map<string, readonly ResolvedCommandEntry<TTarget, TEvent>[]>;
|
|
48
|
+
fallbackWithoutRecord: Map<string, ResolvedBindingCommand<TTarget, TEvent> | null>;
|
|
49
|
+
fallbackWithRecord: Map<string, ResolvedBindingCommand<TTarget, TEvent> | null>;
|
|
50
|
+
fallbackWithoutRecordErrors: Set<string>;
|
|
51
|
+
fallbackWithRecordErrors: Set<string>;
|
|
52
|
+
}
|
|
53
|
+
export interface CommandsState<TTarget extends object, TEvent extends KeymapEvent> {
|
|
54
|
+
commandMetadataVersion: number;
|
|
55
|
+
registeredNames: Map<string, number>;
|
|
56
|
+
commandResolvers: OrderedRegistry<CommandResolver<TTarget, TEvent>>;
|
|
57
|
+
activeCommandViewVersion: number;
|
|
58
|
+
activeCommandView?: ActiveCommandView<TTarget, TEvent>;
|
|
59
|
+
registeredCommandEntriesCacheVersion: number;
|
|
60
|
+
registeredCommandEntriesCache: readonly LayerCommandEntry<TTarget, TEvent>[];
|
|
61
|
+
}
|
|
62
|
+
export interface ProjectionState<TTarget extends object, TEvent extends KeymapEvent> {
|
|
63
|
+
pendingSequence: PendingSequenceState<TTarget, TEvent> | null;
|
|
64
|
+
pendingSequenceCacheVersion: number;
|
|
65
|
+
pendingSequenceCache: readonly KeySequencePart[];
|
|
66
|
+
activeKeysPlainCacheVersion: number;
|
|
67
|
+
activeKeysPlainCache: readonly ActiveKey<TTarget, TEvent>[];
|
|
68
|
+
activeKeysBindingsCacheVersion: number;
|
|
69
|
+
activeKeysBindingsCache: readonly ActiveKey<TTarget, TEvent>[];
|
|
70
|
+
activeKeysMetadataCacheVersion: number;
|
|
71
|
+
activeKeysMetadataCache: readonly ActiveKey<TTarget, TEvent>[];
|
|
72
|
+
activeKeysBindingsAndMetadataCacheVersion: number;
|
|
73
|
+
activeKeysBindingsAndMetadataCache: readonly ActiveKey<TTarget, TEvent>[];
|
|
74
|
+
}
|
|
75
|
+
export interface ConditionsState {
|
|
76
|
+
runtimeKeyDependents: Map<string, Set<RuntimeMatchable>>;
|
|
77
|
+
}
|
|
78
|
+
export interface RuntimeState {
|
|
79
|
+
data: EventData;
|
|
80
|
+
dataVersion: number;
|
|
81
|
+
readonlyDataVersion: number;
|
|
82
|
+
readonlyData: Readonly<EventData>;
|
|
83
|
+
}
|
|
84
|
+
export interface NotifyState {
|
|
85
|
+
derivedStateVersion: number;
|
|
86
|
+
stateChangeDepth: number;
|
|
87
|
+
stateChangePending: boolean;
|
|
88
|
+
flushingStateChange: boolean;
|
|
89
|
+
usedWarningKeys: Set<string>;
|
|
90
|
+
}
|
|
91
|
+
export interface State<TTarget extends object, TEvent extends KeymapEvent> {
|
|
92
|
+
core: CoreState;
|
|
93
|
+
environment: EnvironmentState<TTarget, TEvent>;
|
|
94
|
+
dispatch: DispatchState<TEvent>;
|
|
95
|
+
layers: LayersState<TTarget, TEvent>;
|
|
96
|
+
commands: CommandsState<TTarget, TEvent>;
|
|
97
|
+
projection: ProjectionState<TTarget, TEvent>;
|
|
98
|
+
conditions: ConditionsState;
|
|
99
|
+
runtime: RuntimeState;
|
|
100
|
+
notify: NotifyState;
|
|
101
|
+
}
|
|
102
|
+
export declare function createKeymapState<TTarget extends object, TEvent extends KeymapEvent>(): State<TTarget, TEvent>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function getErrorMessage(error: unknown, fallback: string): string;
|
|
2
|
+
export declare function isPromiseLike(value: unknown): value is Promise<unknown>;
|
|
3
|
+
export declare function snapshotDataValue(value: unknown, options?: {
|
|
4
|
+
deep?: boolean;
|
|
5
|
+
freeze?: boolean;
|
|
6
|
+
preserveNonPlainObjects?: boolean;
|
|
7
|
+
}): unknown;
|