@opentui/keymap 0.2.1 → 0.2.3
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/README.md +64 -30
- package/chunks/index-frk6sdcd.js +409 -0
- package/chunks/index-frk6sdcd.js.map +14 -0
- package/package.json +43 -23
- package/src/addons/index.js +1130 -0
- package/src/addons/index.js.map +25 -0
- package/src/addons/opentui/edit-buffer-bindings.d.ts +6 -2
- package/src/addons/opentui/index.d.ts +2 -2
- package/src/addons/opentui/index.js +467 -0
- package/src/addons/opentui/index.js.map +12 -0
- package/src/addons/universal/binding-overrides.d.ts +6 -0
- package/src/addons/universal/dead-bindings.d.ts +1 -1
- package/src/addons/universal/default-parser.d.ts +2 -2
- package/src/addons/universal/ex-commands.d.ts +11 -8
- package/src/addons/universal/index.d.ts +3 -1
- package/src/addons/universal/leader.d.ts +1 -1
- package/src/addons/universal/metadata.d.ts +2 -2
- package/src/addons/universal/mod-bindings.d.ts +6 -0
- package/src/addons/universal/unresolved-commands.d.ts +1 -1
- package/src/extras/binding-sections.d.ts +18 -0
- package/src/extras/command-bindings.d.ts +19 -0
- package/src/extras/formatting.d.ts +27 -0
- package/src/extras/graph.d.ts +9 -0
- package/src/extras/graph.js +373 -0
- package/src/extras/graph.js.map +11 -0
- package/src/extras/index.d.ts +6 -0
- package/src/extras/index.js +239 -0
- package/src/extras/index.js.map +12 -0
- package/src/extras/lib/graph-snapshot.d.ts +14 -0
- package/src/extras/lib/graph-types.d.ts +83 -0
- package/src/html.d.ts +3 -3
- package/src/html.js +297 -0
- package/src/html.js.map +10 -0
- package/src/index.d.ts +3 -1
- package/src/index.js +4492 -0
- package/src/index.js.map +34 -0
- package/src/keymap.d.ts +23 -35
- package/src/lib/emitter.d.ts +1 -2
- package/src/lib/registry.d.ts +2 -2
- package/src/lib/runtime-utils.d.ts +34 -0
- package/src/opentui.d.ts +1 -3
- package/src/opentui.js +133 -0
- package/src/opentui.js.map +10 -0
- package/src/react/index.d.ts +5 -19
- package/{react → src/react}/index.js +3 -0
- package/src/react/index.js.map +10 -0
- package/src/runtime-modules.d.ts +20 -0
- package/src/runtime-modules.js +28 -0
- package/src/runtime-modules.js.map +10 -0
- package/src/services/activation.d.ts +7 -33
- package/src/services/active-key-cache.d.ts +29 -0
- package/src/services/command-catalog.d.ts +28 -45
- package/src/services/command-executor.d.ts +7 -13
- package/src/services/compiler.d.ts +6 -12
- package/src/services/conditions.d.ts +4 -16
- package/src/services/dispatch-decisions.d.ts +21 -0
- package/src/services/dispatch-patterns.d.ts +5 -0
- package/src/services/dispatch.d.ts +6 -42
- package/src/services/environment.d.ts +6 -21
- package/src/services/extension-context.d.ts +16 -0
- package/src/services/layer-diagnostics.d.ts +10 -0
- package/src/services/layers.d.ts +15 -23
- package/src/services/notify.d.ts +6 -8
- package/src/services/pending-sequence.d.ts +4 -0
- package/src/services/primitives/active-layers.d.ts +2 -3
- package/src/services/primitives/bindings.d.ts +4 -0
- package/src/services/primitives/command-normalization.d.ts +3 -0
- package/src/services/primitives/field-invariants.d.ts +16 -1
- package/src/services/primitives/pending-captures.d.ts +5 -0
- package/src/services/runtime-view.d.ts +5 -0
- package/src/services/runtime.d.ts +2 -7
- package/src/services/sequence-index.d.ts +24 -0
- package/src/services/state.d.ts +46 -91
- package/src/solid/index.d.ts +5 -19
- package/{solid → src/solid}/index.js +3 -0
- package/src/solid/index.js.map +10 -0
- package/src/testing/index.d.ts +90 -0
- package/src/testing/index.js +276 -0
- package/src/testing/index.js.map +10 -0
- package/src/types.d.ts +194 -126
- package/addons/index.js +0 -5240
- package/addons/opentui/index.js +0 -5632
- package/html.js +0 -5042
- package/index.js +0 -4411
- package/opentui.js +0 -4887
- package/src/services/primitives/binding-inputs.d.ts +0 -4
|
@@ -1,61 +1,44 @@
|
|
|
1
|
-
import type { Attributes,
|
|
1
|
+
import type { ActiveBinding, Attributes, Command, CommandEntry, CommandBindingsQuery, CommandResolutionStatus, CommandQuery, CommandResolver, BindingState, KeymapEvent, KeymapHost, CommandState } from "../types.js";
|
|
2
2
|
import type { ConditionService } from "./conditions.js";
|
|
3
3
|
import type { NotificationService } from "./notify.js";
|
|
4
|
-
import type { ActiveCommandView,
|
|
4
|
+
import type { ActiveCommandView, ResolvedCommandEntry, State } from "./state.js";
|
|
5
5
|
interface CommandCatalogOptions {
|
|
6
6
|
onCommandResolversChanged(): void;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
normalizeCommands(commands: readonly
|
|
8
|
+
interface ResolvedCommandLookup<TTarget extends object, TEvent extends KeymapEvent> {
|
|
9
|
+
resolved?: ResolvedCommandEntry<TTarget, TEvent>;
|
|
10
|
+
hadError: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface CommandExecutionFields {
|
|
13
|
+
input: string;
|
|
14
|
+
payload?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface CommandCatalogService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
17
|
+
normalizeCommands(commands: readonly Command<TTarget, TEvent>[]): CommandState<TTarget, TEvent>[];
|
|
18
18
|
prependCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
19
19
|
appendCommandResolver(resolver: CommandResolver<TTarget, TEvent>): () => void;
|
|
20
20
|
clearCommandResolvers(): void;
|
|
21
|
-
getCommands(query?: CommandQuery<TTarget>): readonly
|
|
22
|
-
getCommandEntries(query?: CommandQuery<TTarget>): readonly CommandEntry<TTarget, TEvent>[];
|
|
23
|
-
|
|
21
|
+
getCommands(query?: CommandQuery<TTarget, TEvent>): readonly Command<TTarget, TEvent>[];
|
|
22
|
+
getCommandEntries(query?: CommandQuery<TTarget, TEvent>): readonly CommandEntry<TTarget, TEvent>[];
|
|
23
|
+
getCommandBindings(query: CommandBindingsQuery<TTarget>): ReadonlyMap<string, readonly ActiveBinding<TTarget, TEvent>[]>;
|
|
24
|
+
getResolvedCommandChain(command: string, focused: TTarget | null, execution?: CommandExecutionFields): {
|
|
24
25
|
entries?: readonly ResolvedCommandEntry<TTarget, TEvent>[];
|
|
25
26
|
hadError: boolean;
|
|
26
27
|
};
|
|
27
|
-
getRegisteredResolvedEntries(command: string
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
getTopCommandRecord(command: string, focused: TTarget | null): CommandRecord | undefined;
|
|
34
|
-
getTopRegisteredCommandRecord(command: string): CommandRecord | undefined;
|
|
35
|
-
getDispatchUnavailableCommandState(command: string, focused: TTarget | null, includeRecord: boolean): {
|
|
28
|
+
getRegisteredResolvedEntries(command: string): readonly ResolvedCommandEntry<TTarget, TEvent>[] | undefined;
|
|
29
|
+
getActiveRegisteredResolvedEntries(command: string, focused: TTarget | null): readonly ResolvedCommandEntry<TTarget, TEvent>[] | undefined;
|
|
30
|
+
resolveRegisteredResolverFallback(command: string, execution?: CommandExecutionFields): ResolvedCommandLookup<TTarget, TEvent>;
|
|
31
|
+
resolveActiveResolverFallback(command: string, focused: TTarget | null, execution?: CommandExecutionFields): ResolvedCommandLookup<TTarget, TEvent>;
|
|
32
|
+
getTopCommand(command: string, focused: TTarget | null): Command<TTarget, TEvent> | undefined;
|
|
33
|
+
getDispatchUnavailableCommandState(command: string, focused: TTarget | null, includeCommand: boolean): {
|
|
36
34
|
reason: "inactive" | "disabled";
|
|
37
|
-
command?:
|
|
35
|
+
command?: Command<TTarget, TEvent>;
|
|
38
36
|
} | undefined;
|
|
39
37
|
getActiveCommandView(focused: TTarget | null): ActiveCommandView<TTarget, TEvent>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
getCommandResolutionStatus(command: string, layerCommands?: ReadonlyMap<string, RegisteredCommand<TTarget, TEvent>>): CommandResolutionStatus;
|
|
44
|
-
private mutateCommandResolvers;
|
|
45
|
-
private getTopResolvedCommand;
|
|
46
|
-
private getTopRegisteredCommand;
|
|
47
|
-
private getFallbackResolvedCommand;
|
|
48
|
-
private getResolvedCommandChainFromView;
|
|
49
|
-
private getRegisteredLayerCommandEntries;
|
|
50
|
-
private getCommandQueryContext;
|
|
51
|
-
private getFilteredCommandEntries;
|
|
52
|
-
private collectCommandEntryBindings;
|
|
53
|
-
private collectBindingForCommandEntries;
|
|
54
|
-
private resolveCommandWithResolvers;
|
|
55
|
-
private createCommandResolverContext;
|
|
38
|
+
isBindingVisible(binding: BindingState<TTarget, TEvent>, focused: TTarget | null, activeView: ActiveCommandView<TTarget, TEvent>): boolean;
|
|
39
|
+
getBindingCommandAttrs(binding: BindingState<TTarget, TEvent>, focused: TTarget | null, activeView: ActiveCommandView<TTarget, TEvent>): Readonly<Attributes> | undefined;
|
|
40
|
+
getCommandResolutionStatus(command: string, layerCommands?: readonly CommandState<TTarget, TEvent>[]): CommandResolutionStatus;
|
|
56
41
|
}
|
|
57
|
-
export declare function
|
|
58
|
-
export declare function
|
|
59
|
-
includeRecord?: boolean;
|
|
60
|
-
}): ResolvedBindingCommand<TTarget, TEvent>;
|
|
42
|
+
export declare function createCommandCatalogService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, host: KeymapHost<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, options: CommandCatalogOptions): CommandCatalogService<TTarget, TEvent>;
|
|
43
|
+
export declare function getCommand<TTarget extends object, TEvent extends KeymapEvent>(state: CommandState<TTarget, TEvent>): Command<TTarget, TEvent>;
|
|
61
44
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Keymap } from "../keymap.js";
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { BindingState, KeymapEvent, RegisteredLayer, RunCommandOptions, RunCommandResult } from "../types.js";
|
|
3
|
+
import type { CommandCatalogService } from "./command-catalog.js";
|
|
4
4
|
import type { ActivationService } from "./activation.js";
|
|
5
5
|
import type { NotificationService } from "./notify.js";
|
|
6
6
|
import type { RuntimeService } from "./runtime.js";
|
|
@@ -8,16 +8,10 @@ interface CommandExecutorOptions<TTarget extends object, TEvent extends KeymapEv
|
|
|
8
8
|
keymap: Keymap<TTarget, TEvent>;
|
|
9
9
|
createCommandEvent: () => TEvent;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
dispatchCommand(cmd: string, options?: RunCommandOptions<TTarget, TEvent>): RunCommandResult;
|
|
20
|
-
runBinding(bindingLayer: RegisteredLayer<TTarget, TEvent>, binding: CompiledBinding<TTarget, TEvent>, event: TEvent, focused: TTarget | null): boolean;
|
|
21
|
-
private executeResolvedCommand;
|
|
11
|
+
export interface CommandExecutorService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
12
|
+
runCommand(cmd: string, options?: RunCommandOptions<TTarget, TEvent>): RunCommandResult<TTarget, TEvent>;
|
|
13
|
+
dispatchCommand(cmd: string, options?: RunCommandOptions<TTarget, TEvent>): RunCommandResult<TTarget, TEvent>;
|
|
14
|
+
runBinding(bindingLayer: RegisteredLayer<TTarget, TEvent>, binding: BindingState<TTarget, TEvent>, event: TEvent, focused: TTarget | null, payload?: unknown): boolean;
|
|
22
15
|
}
|
|
16
|
+
export declare function createCommandExecutorService<TTarget extends object, TEvent extends KeymapEvent>(notify: NotificationService<TTarget, TEvent>, runtime: RuntimeService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>, catalog: CommandCatalogService<TTarget, TEvent>, options: CommandExecutorOptions<TTarget, TEvent>): CommandExecutorService<TTarget, TEvent>;
|
|
23
17
|
export {};
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import type { ConditionService } from "./conditions.js";
|
|
2
2
|
import type { State } from "./state.js";
|
|
3
3
|
import type { NotificationService } from "./notify.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Binding, BindingCompilationResult, KeyLike, KeymapEvent, KeySequencePart, ResolvedKeyToken, StringifyOptions } from "../types.js";
|
|
5
5
|
export interface CompilerOptions {
|
|
6
6
|
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
7
7
|
warnUnknownToken: (token: string, sequence: string) => void;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
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);
|
|
9
|
+
export interface CompilerService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
15
10
|
parseTokenKey(key: KeyLike): KeySequencePart;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
private applyBindingTransformers;
|
|
20
|
-
private insertBinding;
|
|
11
|
+
parseKeySequence(key: KeyLike): KeySequencePart[];
|
|
12
|
+
formatKey(key: KeyLike, options?: StringifyOptions): string;
|
|
13
|
+
compileBindings(bindings: readonly Binding<TTarget, TEvent>[], tokens: ReadonlyMap<string, ResolvedKeyToken>, sourceTarget: TTarget | undefined, sourceLayerOrder: number, fields?: Readonly<Record<string, unknown>>): BindingCompilationResult<TTarget, TEvent>;
|
|
21
14
|
}
|
|
15
|
+
export declare function createCompilerService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, options: CompilerOptions): CompilerService<TTarget, TEvent>;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import type { NotificationService } from "./notify.js";
|
|
2
1
|
import type { State } from "./state.js";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
private readonly notify;
|
|
7
|
-
constructor(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>);
|
|
2
|
+
import type { NotificationService } from "./notify.js";
|
|
3
|
+
import type { KeymapEvent, ReactiveMatcher, RuntimeMatchable, RuntimeMatcher } from "../types.js";
|
|
4
|
+
export interface ConditionService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
8
5
|
buildRuntimeMatcher(matcher: (() => boolean) | ReactiveMatcher, source: string): RuntimeMatcher;
|
|
9
|
-
hasNoConditions(target: RuntimeMatchable): boolean;
|
|
10
|
-
indexRuntimeMatchable(target: RuntimeMatchable): void;
|
|
11
|
-
unindexRuntimeMatchable(target: RuntimeMatchable): void;
|
|
12
|
-
invalidateRuntimeConditionKey(name: string): void;
|
|
13
6
|
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
7
|
}
|
|
8
|
+
export declare function createConditionService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>): ConditionService<TTarget, TEvent>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { KeyDeferredDisambiguationDecision, KeyDeferredDisambiguationHandler, KeyDisambiguationDecision, KeymapEvent, PendingSequenceCapture } from "../types.js";
|
|
2
|
+
export type SyncDecisionAction = "run-exact" | "continue-sequence" | "clear" | "defer";
|
|
3
|
+
export type DeferredDecisionAction = "run-exact" | "continue-sequence" | "clear";
|
|
4
|
+
export interface InternalDisambiguationDecision extends KeyDisambiguationDecision {
|
|
5
|
+
readonly action: SyncDecisionAction;
|
|
6
|
+
readonly handler?: KeyDeferredDisambiguationHandler<any, any>;
|
|
7
|
+
}
|
|
8
|
+
export interface InternalDeferredDisambiguationDecision extends KeyDeferredDisambiguationDecision {
|
|
9
|
+
readonly action: DeferredDecisionAction;
|
|
10
|
+
}
|
|
11
|
+
export interface PendingDisambiguation<TTarget extends object, TEvent extends KeymapEvent> {
|
|
12
|
+
id: number;
|
|
13
|
+
controller: AbortController;
|
|
14
|
+
captures: readonly PendingSequenceCapture<TTarget, TEvent>[];
|
|
15
|
+
apply: (decision: InternalDeferredDisambiguationDecision | void) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createSyncDecision(action: SyncDecisionAction, handler?: KeyDeferredDisambiguationHandler<any, any>): InternalDisambiguationDecision;
|
|
18
|
+
export declare function createDeferredDecision(action: DeferredDecisionAction): InternalDeferredDisambiguationDecision;
|
|
19
|
+
export declare function isSyncDecision(value: unknown): value is InternalDisambiguationDecision;
|
|
20
|
+
export declare function isDeferredDecision(value: unknown): value is InternalDeferredDisambiguationDecision;
|
|
21
|
+
export declare function sleepWithSignal(ms: number, signal: AbortSignal): Promise<boolean>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeymapEvent, KeySequencePart, PendingSequenceCapture, ResolvedSequencePattern, SequencePatternMatch } from "../types.js";
|
|
2
|
+
import type { NotificationService } from "./notify.js";
|
|
3
|
+
export declare function matchSequencePattern<TTarget extends object, TEvent extends KeymapEvent>(patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, notify: NotificationService<TTarget, TEvent>, patternName: string, event: TEvent): SequencePatternMatch | undefined;
|
|
4
|
+
export declare function createPatternEventPart<TEvent extends KeymapEvent>(patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, event: TEvent, patternName: string, match: SequencePatternMatch): KeySequencePart;
|
|
5
|
+
export declare function createSequencePayload<TTarget extends object, TEvent extends KeymapEvent>(patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, notify: NotificationService<TTarget, TEvent>, capture?: PendingSequenceCapture<TTarget, TEvent>): unknown;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompilerService } from "./compiler.js";
|
|
2
|
+
import type { RuntimeEmitter } from "../lib/runtime-utils.js";
|
|
2
3
|
import type { ActivationService } from "./activation.js";
|
|
3
4
|
import type { CommandExecutorService } from "./command-executor.js";
|
|
4
5
|
import type { CommandCatalogService } from "./command-catalog.js";
|
|
@@ -7,22 +8,10 @@ import type { LayerService } from "./layers.js";
|
|
|
7
8
|
import type { NotificationService } from "./notify.js";
|
|
8
9
|
import type { RuntimeService } from "./runtime.js";
|
|
9
10
|
import type { State } from "./state.js";
|
|
10
|
-
import { type EventMatchResolver, type KeyDisambiguationResolver, type KeyInterceptOptions, type KeyInputContext, type KeymapEvent, type PendingSequenceState, type RawInterceptOptions, type RawInputContext } from "../types.js";
|
|
11
|
-
export
|
|
12
|
-
private readonly state;
|
|
13
|
-
private readonly notify;
|
|
14
|
-
private readonly runtime;
|
|
15
|
-
private readonly activation;
|
|
16
|
-
private readonly conditions;
|
|
17
|
-
private readonly executor;
|
|
18
|
-
private readonly compiler;
|
|
19
|
-
private readonly catalog;
|
|
20
|
-
private readonly layers;
|
|
21
|
-
private readonly eventMatchResolverContext;
|
|
22
|
-
private pendingDisambiguation;
|
|
23
|
-
private nextPendingDisambiguationId;
|
|
24
|
-
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>, catalog: CommandCatalogService<TTarget, TEvent>, layers: LayerService<TTarget, TEvent>);
|
|
11
|
+
import { type EventMatchResolver, type KeyDisambiguationResolver, type KeyInterceptOptions, type KeyAfterInputContext, type KeyInputContext, type KeymapEvent, type PendingSequenceState, type RawInterceptOptions, type RawInputContext, type Hooks } from "../types.js";
|
|
12
|
+
export interface DispatchService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
25
13
|
intercept(name: "key", fn: (ctx: KeyInputContext<TEvent>) => void, options?: KeyInterceptOptions): () => void;
|
|
14
|
+
intercept(name: "key:after", fn: (ctx: KeyAfterInputContext<TTarget, TEvent>) => void, options?: KeyInterceptOptions): () => void;
|
|
26
15
|
intercept(name: "raw", fn: (ctx: RawInputContext) => void, options?: RawInterceptOptions): () => void;
|
|
27
16
|
prependEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
28
17
|
appendEventMatchResolver(resolver: EventMatchResolver<TEvent>): () => void;
|
|
@@ -30,33 +19,8 @@ export declare class DispatchService<TTarget extends object, TEvent extends Keym
|
|
|
30
19
|
prependDisambiguationResolver(resolver: KeyDisambiguationResolver<TTarget, TEvent>): () => void;
|
|
31
20
|
appendDisambiguationResolver(resolver: KeyDisambiguationResolver<TTarget, TEvent>): () => void;
|
|
32
21
|
clearDisambiguationResolvers(): void;
|
|
33
|
-
handlePendingSequenceChange(
|
|
22
|
+
handlePendingSequenceChange(previous: PendingSequenceState<TTarget, TEvent> | null, next: PendingSequenceState<TTarget, TEvent> | null): void;
|
|
34
23
|
handleRawSequence(sequence: string): boolean;
|
|
35
24
|
handleKeyEvent(event: TEvent, release: boolean): void;
|
|
36
|
-
private mutateDisambiguationResolvers;
|
|
37
|
-
private dispatchReleaseLayers;
|
|
38
|
-
private dispatchLayers;
|
|
39
|
-
private dispatchPendingSequence;
|
|
40
|
-
private dispatchPendingCapturesFromIndex;
|
|
41
|
-
private dispatchFromRoot;
|
|
42
|
-
private dispatchFromRootAtIndex;
|
|
43
|
-
private tryResolveRootAmbiguity;
|
|
44
|
-
private tryResolvePendingAmbiguity;
|
|
45
|
-
private tryResolveAmbiguity;
|
|
46
|
-
private applySyncDecision;
|
|
47
|
-
private resolveDisambiguation;
|
|
48
|
-
private scheduleDeferredDisambiguation;
|
|
49
|
-
private executeDeferredDisambiguation;
|
|
50
|
-
private applyDeferredDisambiguationResult;
|
|
51
|
-
private finishPendingDisambiguation;
|
|
52
|
-
private cancelPendingDisambiguation;
|
|
53
|
-
private isPendingDisambiguationCurrent;
|
|
54
|
-
private sleepWithSignal;
|
|
55
|
-
private warnUnresolvedAmbiguity;
|
|
56
|
-
private collectPendingCapturesFromRoot;
|
|
57
|
-
private collectPendingCapturesFromAdvanced;
|
|
58
|
-
private resolveEventMatchKeys;
|
|
59
|
-
private runReleaseBindings;
|
|
60
|
-
private getReachableChild;
|
|
61
|
-
private runBindings;
|
|
62
25
|
}
|
|
26
|
+
export declare function createDispatchService<TTarget extends object, TEvent extends KeymapEvent>(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>, catalog: CommandCatalogService<TTarget, TEvent>, layers: LayerService<TTarget, TEvent>, hooks: RuntimeEmitter<Hooks<TTarget, TEvent>>): DispatchService<TTarget, TEvent>;
|
|
@@ -2,24 +2,9 @@ import type { CompilerService } from "./compiler.js";
|
|
|
2
2
|
import type { LayerService } from "./layers.js";
|
|
3
3
|
import type { NotificationService } from "./notify.js";
|
|
4
4
|
import type { State } from "./state.js";
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
}
|
|
5
|
+
import type { KeyToken, KeymapEvent, SequencePattern } from "../types.js";
|
|
6
|
+
type FieldKind = "layer" | "binding" | "command";
|
|
7
|
+
export declare function registerToken<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, compiler: CompilerService<TTarget, TEvent>, layers: LayerService<TTarget, TEvent>, token: KeyToken): () => void;
|
|
8
|
+
export declare function registerSequencePattern<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, layers: LayerService<TTarget, TEvent>, pattern: SequencePattern<TEvent>): () => void;
|
|
9
|
+
export declare function registerFields<TTarget extends object, TEvent extends KeymapEvent, T>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, kind: FieldKind, fields: Record<string, T>): () => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ActivationService } from "./activation.js";
|
|
2
|
+
import type { CommandCatalogService } from "./command-catalog.js";
|
|
3
|
+
import type { ConditionService } from "./conditions.js";
|
|
4
|
+
import type { State } from "./state.js";
|
|
5
|
+
import type { KeymapEvent, KeymapHost } from "../types.js";
|
|
6
|
+
export declare const KEYMAP_EXTENSION_CONTEXT: unique symbol;
|
|
7
|
+
export interface KeymapExtensionContext<TTarget extends object, TEvent extends KeymapEvent> {
|
|
8
|
+
state: State<TTarget, TEvent>;
|
|
9
|
+
host: KeymapHost<TTarget, TEvent>;
|
|
10
|
+
conditions: ConditionService<TTarget, TEvent>;
|
|
11
|
+
catalog: CommandCatalogService<TTarget, TEvent>;
|
|
12
|
+
activation: ActivationService<TTarget, TEvent>;
|
|
13
|
+
}
|
|
14
|
+
export interface KeymapExtensionProvider<TTarget extends object, TEvent extends KeymapEvent> {
|
|
15
|
+
[KEYMAP_EXTENSION_CONTEXT](): KeymapExtensionContext<TTarget, TEvent>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandCatalogService } from "./command-catalog.js";
|
|
2
|
+
import type { LayerDiagnostics } from "./layers.js";
|
|
3
|
+
import type { NotificationService } from "./notify.js";
|
|
4
|
+
import type { KeymapEvent, LayerAnalyzer } from "../types.js";
|
|
5
|
+
export interface LayerDiagnosticsCore<TTarget extends object, TEvent extends KeymapEvent> extends LayerDiagnostics<TTarget, TEvent> {
|
|
6
|
+
prependLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
7
|
+
appendLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
8
|
+
clearLayerAnalyzers(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLayerDiagnostics<TTarget extends object, TEvent extends KeymapEvent>(notify: NotificationService<TTarget, TEvent>, commands: CommandCatalogService<TTarget, TEvent>): LayerDiagnosticsCore<TTarget, TEvent>;
|
package/src/services/layers.d.ts
CHANGED
|
@@ -2,40 +2,32 @@ import type { CompilerService } from "./compiler.js";
|
|
|
2
2
|
import type { CommandCatalogService } from "./command-catalog.js";
|
|
3
3
|
import type { ConditionService } from "./conditions.js";
|
|
4
4
|
import type { ActivationService } from "./activation.js";
|
|
5
|
-
import type { KeymapEvent, KeymapHost, Layer,
|
|
5
|
+
import type { Binding, BindingState, KeymapEvent, KeymapHost, Layer, ResolvedKeyToken, CommandState } from "../types.js";
|
|
6
6
|
import type { State } from "./state.js";
|
|
7
7
|
import type { NotificationService } from "./notify.js";
|
|
8
8
|
interface LayersOptions<TTarget extends object, TEvent extends KeymapEvent> {
|
|
9
9
|
compiler: CompilerService<TTarget, TEvent>;
|
|
10
10
|
commands: CommandCatalogService<TTarget, TEvent>;
|
|
11
11
|
host: KeymapHost<TTarget, TEvent>;
|
|
12
|
+
diagnostics?: LayerDiagnostics<TTarget, TEvent>;
|
|
12
13
|
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export interface AnalyzeLayerOptions<TTarget extends object, TEvent extends KeymapEvent> {
|
|
16
|
+
target?: TTarget;
|
|
17
|
+
order: number;
|
|
18
|
+
commands: readonly CommandState<TTarget, TEvent>[];
|
|
19
|
+
sourceBindings: readonly Binding<TTarget, TEvent>[];
|
|
20
|
+
bindings: readonly BindingState<TTarget, TEvent>[];
|
|
21
|
+
hasTokenBindings: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface LayerDiagnostics<TTarget extends object, TEvent extends KeymapEvent> {
|
|
24
|
+
analyzeLayer(options: AnalyzeLayerOptions<TTarget, TEvent>): void;
|
|
25
|
+
}
|
|
26
|
+
export interface LayerService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
21
27
|
registerLayer(layer: Layer<TTarget, TEvent>): () => void;
|
|
22
28
|
applyTokenState(nextTokens: Map<string, ResolvedKeyToken>): void;
|
|
23
29
|
recompileBindings(): void;
|
|
24
|
-
prependLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
25
|
-
appendLayerAnalyzer(analyzer: LayerAnalyzer<TTarget, TEvent>): () => void;
|
|
26
|
-
clearLayerAnalyzers(): void;
|
|
27
30
|
cleanup(): void;
|
|
28
|
-
private normalizeTargetMode;
|
|
29
|
-
private runLayerAnalyzers;
|
|
30
|
-
private compileLayerRuntimeState;
|
|
31
|
-
private compileLayerBindings;
|
|
32
|
-
private applyCompiledBindings;
|
|
33
|
-
private indexLayer;
|
|
34
|
-
private removeLayerFromIndex;
|
|
35
|
-
private unregisterLayer;
|
|
36
|
-
private connectRuntimeMatchable;
|
|
37
|
-
private disconnectRuntimeMatchable;
|
|
38
|
-
private attachReactiveMatchers;
|
|
39
|
-
private detachReactiveMatchers;
|
|
40
31
|
}
|
|
32
|
+
export declare function createLayerService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>, options: LayersOptions<TTarget, TEvent>): LayerService<TTarget, TEvent>;
|
|
41
33
|
export {};
|
package/src/services/notify.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { Events, HookName, Hooks, KeymapEvent } from "../types.js";
|
|
2
|
+
import type { RuntimeEmitter } from "../lib/runtime-utils.js";
|
|
2
3
|
import type { State } from "./state.js";
|
|
3
|
-
import { Emitter } from "../lib/emitter.js";
|
|
4
4
|
type DiagnosticEvents<TTarget extends object, TEvent extends KeymapEvent> = Pick<Events<TTarget, TEvent>, "warning" | "error">;
|
|
5
5
|
export declare const MAX_STATE_CHANGE_FLUSH_ITERATIONS = 1000;
|
|
6
|
-
export
|
|
7
|
-
private readonly state;
|
|
8
|
-
private readonly events;
|
|
9
|
-
private readonly hooks;
|
|
10
|
-
constructor(state: State<TTarget, TEvent>, events: Emitter<DiagnosticEvents<TTarget, TEvent>>, hooks: Emitter<Hooks<TTarget, TEvent>>);
|
|
6
|
+
export interface NotificationService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
11
7
|
runWithStateChangeBatch<T>(fn: () => T): T;
|
|
12
|
-
queueStateChange(
|
|
8
|
+
queueStateChange(options?: {
|
|
9
|
+
invalidateCaches?: boolean;
|
|
10
|
+
}): void;
|
|
13
11
|
emitWarning(code: string, warning: unknown, message: string): void;
|
|
14
12
|
emitError(code: string, error: unknown, message: string): void;
|
|
15
13
|
reportListenerError(name: HookName, error: unknown): void;
|
|
16
14
|
warnOnce(key: string, code: string, warning: unknown, message: string): void;
|
|
17
|
-
private flushStateChange;
|
|
18
15
|
}
|
|
16
|
+
export declare function createNotificationService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, events: RuntimeEmitter<DiagnosticEvents<TTarget, TEvent>>, hooks: RuntimeEmitter<Hooks<TTarget, TEvent>>): NotificationService<TTarget, TEvent>;
|
|
19
17
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { KeymapEvent, KeySequencePart, PendingSequenceCapture, PendingSequenceState } from "../types.js";
|
|
2
|
+
export declare function isSamePendingSequence<TTarget extends object, TEvent extends KeymapEvent>(current: PendingSequenceState<TTarget, TEvent> | null, next: PendingSequenceState<TTarget, TEvent> | null): boolean;
|
|
3
|
+
export declare function popCapture<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>): PendingSequenceCapture<TTarget, TEvent> | undefined;
|
|
4
|
+
export declare function collectSequencePartsFromPending<TTarget extends object, TEvent extends KeymapEvent>(pending: PendingSequenceState<TTarget, TEvent>): KeySequencePart[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { KeymapEvent, KeymapHost, RegisteredLayer } from "../../types.js";
|
|
2
|
-
import type { LayersState } from "../state.js";
|
|
3
2
|
export declare function getFocusedTargetIfAvailable<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>): TTarget | null;
|
|
4
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;
|
|
5
4
|
export declare function getActivationPath<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>, focused: TTarget | null): Set<TTarget>;
|
|
6
|
-
export declare function getActiveLayersForFocused<TTarget extends object, TEvent extends KeymapEvent>(
|
|
7
|
-
export declare function
|
|
5
|
+
export declare function getActiveLayersForFocused<TTarget extends object, TEvent extends KeymapEvent>(layers: readonly RegisteredLayer<TTarget, TEvent>[] | ReadonlySet<RegisteredLayer<TTarget, TEvent>>, host: KeymapHost<TTarget, TEvent>, focused: TTarget | null): readonly RegisteredLayer<TTarget, TEvent>[];
|
|
6
|
+
export declare function getSortedLayers<TTarget extends object, TEvent extends KeymapEvent>(layers: ReadonlySet<RegisteredLayer<TTarget, TEvent>>): RegisteredLayer<TTarget, TEvent>[];
|
|
8
7
|
export declare function isLayerActiveForFocused<TTarget extends object, TEvent extends KeymapEvent>(host: KeymapHost<TTarget, TEvent>, layer: RegisteredLayer<TTarget, TEvent>, focused: TTarget | null, activationPath?: ReadonlySet<TTarget>): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Binding, BindingsValidationResult, Bindings, KeymapEvent, ParsedBinding } from "../../types.js";
|
|
2
|
+
export declare function validateBindings(bindings: unknown): BindingsValidationResult;
|
|
3
|
+
export declare function snapshotBindings<TTarget extends object, TEvent extends KeymapEvent>(bindings: Bindings<TTarget, TEvent>): Binding<TTarget, TEvent>[];
|
|
4
|
+
export declare function snapshotParsedBinding<TTarget extends object, TEvent extends KeymapEvent>(binding: ParsedBinding<TTarget, TEvent>): ParsedBinding<TTarget, TEvent>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BindingCommand, KeymapEvent } from "../../types.js";
|
|
2
|
+
export declare function normalizeBindingCommand<TTarget extends object, TEvent extends KeymapEvent>(command: BindingCommand<TTarget, TEvent> | undefined): BindingCommand<TTarget, TEvent> | undefined;
|
|
3
|
+
export declare function normalizeCommandName(name: string): string;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import type { Attributes, EventData } from "../../types.js";
|
|
1
|
+
import type { Attributes, BindingFieldContext, CommandFieldContext, EventData, KeymapEvent, LayerFieldContext, RuntimeMatcher } from "../../types.js";
|
|
2
|
+
import type { ConditionService } from "../conditions.js";
|
|
2
3
|
export declare function mergeRequirement(target: EventData, name: string, value: unknown, source: string): void;
|
|
3
4
|
export declare function mergeAttribute(target: Attributes, name: string, value: unknown, source: string): void;
|
|
5
|
+
interface FieldCompilerContextOptions<TTarget extends object, TEvent extends KeymapEvent> {
|
|
6
|
+
fieldName: string;
|
|
7
|
+
conditions: ConditionService<TTarget, TEvent>;
|
|
8
|
+
requirements: EventData;
|
|
9
|
+
matchers: RuntimeMatcher[];
|
|
10
|
+
attrs?: Attributes;
|
|
11
|
+
}
|
|
12
|
+
export declare function createFieldCompilerContext<TTarget extends object, TEvent extends KeymapEvent>(options: FieldCompilerContextOptions<TTarget, TEvent> & {
|
|
13
|
+
attrs: Attributes;
|
|
14
|
+
}): BindingFieldContext & CommandFieldContext & LayerFieldContext;
|
|
15
|
+
export declare function createFieldCompilerContext<TTarget extends object, TEvent extends KeymapEvent>(options: FieldCompilerContextOptions<TTarget, TEvent> & {
|
|
16
|
+
attrs?: undefined;
|
|
17
|
+
}): LayerFieldContext;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeymapEvent, PendingSequenceCapture, ResolvedSequencePattern } from "../../types.js";
|
|
2
|
+
export declare function patternCaptureCount<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>): number;
|
|
3
|
+
export declare function captureHasMinimum<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>, patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, missingPatternResult?: boolean): boolean;
|
|
4
|
+
export declare function captureHasContinuations<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>, patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, missingPatternMinimum?: boolean): boolean;
|
|
5
|
+
export declare function captureIsExact<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>, patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ConditionService } from "./conditions.js";
|
|
2
|
+
import type { ActiveCommandView, CommandView, State } from "./state.js";
|
|
3
|
+
import type { KeymapEvent, KeymapHost } from "../types.js";
|
|
4
|
+
export declare function getRegisteredCommandView<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>): CommandView<TTarget, TEvent>;
|
|
5
|
+
export declare function getActiveCommandView<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, host: KeymapHost<TTarget, TEvent>, conditions: ConditionService<TTarget, TEvent>, focused: TTarget | null): ActiveCommandView<TTarget, TEvent>;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import type { EventData, KeymapEvent } from "../types.js";
|
|
2
2
|
import type { ActivationService } from "./activation.js";
|
|
3
|
-
import type { ConditionService } from "./conditions.js";
|
|
4
3
|
import type { NotificationService } from "./notify.js";
|
|
5
4
|
import type { State } from "./state.js";
|
|
6
|
-
export
|
|
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>);
|
|
5
|
+
export interface RuntimeService<TTarget extends object, TEvent extends KeymapEvent> {
|
|
12
6
|
getData(name: string): unknown;
|
|
13
7
|
setData(name: string, value: unknown): void;
|
|
14
8
|
getReadonlyData(): Readonly<EventData>;
|
|
15
9
|
}
|
|
10
|
+
export declare function createRuntimeService<TTarget extends object, TEvent extends KeymapEvent>(state: State<TTarget, TEvent>, notify: NotificationService<TTarget, TEvent>, activation: ActivationService<TTarget, TEvent>): RuntimeService<TTarget, TEvent>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BindingState, KeymapEvent, KeySequencePart, KeyMatch, PendingSequenceCapture, PendingSequencePatternCapture, RegisteredLayer, ResolvedSequencePattern, SequenceNode, SequencePatternMatch } from "../types.js";
|
|
2
|
+
export interface SequenceActiveOption<TTarget extends object, TEvent extends KeymapEvent> {
|
|
3
|
+
part: KeySequencePart;
|
|
4
|
+
binding: BindingState<TTarget, TEvent>;
|
|
5
|
+
index: number;
|
|
6
|
+
exact: boolean;
|
|
7
|
+
continues: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSequenceNode<TTarget extends object, TEvent extends KeymapEvent>(parent: SequenceNode<TTarget, TEvent> | null, stroke: KeySequencePart["stroke"] | null, match: KeySequencePart["match"] | null, pattern?: ResolvedSequencePattern<TEvent>): SequenceNode<TTarget, TEvent>;
|
|
10
|
+
export declare function buildSequenceTree<TTarget extends object, TEvent extends KeymapEvent>(bindings: readonly BindingState<TTarget, TEvent>[], patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>): SequenceNode<TTarget, TEvent>;
|
|
11
|
+
export declare function getCaptureNode<TTarget extends object, TEvent extends KeymapEvent>(root: SequenceNode<TTarget, TEvent>, capture: import("../types.js").PendingSequenceCapture<TTarget, TEvent>): SequenceNode<TTarget, TEvent> | undefined;
|
|
12
|
+
export declare function getNodeSequence<TTarget extends object, TEvent extends KeymapEvent>(node: SequenceNode<TTarget, TEvent>): KeySequencePart[];
|
|
13
|
+
export declare function getNodePresentation<TTarget extends object, TEvent extends KeymapEvent>(node: SequenceNode<TTarget, TEvent>): {
|
|
14
|
+
display: string;
|
|
15
|
+
tokenName?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function firstNodeForMatch<TTarget extends object, TEvent extends KeymapEvent>(root: SequenceNode<TTarget, TEvent>, match: KeyMatch): SequenceNode<TTarget, TEvent> | undefined;
|
|
18
|
+
export declare function childNodes<TTarget extends object, TEvent extends KeymapEvent>(node: SequenceNode<TTarget, TEvent>): SequenceNode<TTarget, TEvent>[];
|
|
19
|
+
export declare function activeOptionsForBindings<TTarget extends object, TEvent extends KeymapEvent>(bindings: readonly BindingState<TTarget, TEvent>[]): SequenceActiveOption<TTarget, TEvent>[];
|
|
20
|
+
export declare function activeOptionsForCaptures<TTarget extends object, TEvent extends KeymapEvent>(captures: readonly PendingSequenceCapture<TTarget, TEvent>[], patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>): SequenceActiveOption<TTarget, TEvent>[];
|
|
21
|
+
export declare function capturePriority<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>, matchKeys: readonly KeyMatch[]): number;
|
|
22
|
+
export declare function advanceSequenceBinding<TTarget extends object, TEvent extends KeymapEvent>(layer: RegisteredLayer<TTarget, TEvent>, binding: BindingState<TTarget, TEvent>, index: number, parts: readonly KeySequencePart[], patterns: readonly PendingSequencePatternCapture[] | undefined, matchKeys: readonly KeyMatch[], event: TEvent, matchPattern: (patternName: string, event: TEvent) => SequencePatternMatch | undefined, createPatternPart: (event: TEvent, patternName: string, match: SequencePatternMatch) => KeySequencePart): PendingSequenceCapture<TTarget, TEvent> | undefined;
|
|
23
|
+
export declare function advanceSequenceCapture<TTarget extends object, TEvent extends KeymapEvent>(capture: PendingSequenceCapture<TTarget, TEvent>, matchKeys: readonly KeyMatch[], event: TEvent, patterns: ReadonlyMap<string, ResolvedSequencePattern<TEvent>>, matchPattern: (patternName: string, event: TEvent) => SequencePatternMatch | undefined, createPatternPart: (event: TEvent, patternName: string, match: SequencePatternMatch) => KeySequencePart): PendingSequenceCapture<TTarget, TEvent> | undefined;
|
|
24
|
+
export declare function collectRootSequenceCaptures<TTarget extends object, TEvent extends KeymapEvent>(layer: RegisteredLayer<TTarget, TEvent>, matchKeys: readonly KeyMatch[], event: TEvent, matchPattern: (patternName: string, event: TEvent) => SequencePatternMatch | undefined, createPatternPart: (event: TEvent, patternName: string, match: SequencePatternMatch) => KeySequencePart): PendingSequenceCapture<TTarget, TEvent>[];
|