@opentui/core 0.0.0-20260412-2fcfd0af → 0.0.0-20260419-49f00f96
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/3d.js +1 -1
- package/Renderable.d.ts +3 -1
- package/console.d.ts +3 -1
- package/extras/index.d.ts +1 -0
- package/extras/keymap/addons/aliases.d.ts +3 -0
- package/extras/keymap/addons/backspace-pops-pending-sequence.d.ts +10 -0
- package/extras/keymap/addons/base-layout.d.ts +2 -0
- package/extras/keymap/addons/comma-bindings.d.ts +2 -0
- package/extras/keymap/addons/dead-bindings.d.ts +2 -0
- package/extras/keymap/addons/edit-buffer-bindings.d.ts +37 -0
- package/extras/keymap/addons/emacs-bindings.d.ts +2 -0
- package/extras/keymap/addons/enabled.d.ts +7 -0
- package/extras/keymap/addons/escape-clears-pending-sequence.d.ts +10 -0
- package/extras/keymap/addons/ex-commands.d.ts +12 -0
- package/extras/keymap/addons/index.d.ts +21 -0
- package/extras/keymap/addons/leader.d.ts +6 -0
- package/extras/keymap/addons/metadata.d.ts +2 -0
- package/extras/keymap/addons/timed-leader.d.ts +8 -0
- package/extras/keymap/index.d.ts +6 -0
- package/extras/keymap/keymap.d.ts +79 -0
- package/extras/keymap/lib/default-parser.d.ts +6 -0
- package/extras/keymap/lib/emitter.d.ts +13 -0
- package/extras/keymap/lib/named-keys.d.ts +2 -0
- package/extras/keymap/lib/registry.d.ts +28 -0
- package/extras/keymap/lib/utils.d.ts +48 -0
- package/extras/keymap/schema.d.ts +3 -0
- package/extras/keymap/services/commands.d.ts +42 -0
- package/extras/keymap/services/compiler.d.ts +26 -0
- package/extras/keymap/services/conditions.d.ts +20 -0
- package/extras/keymap/services/dispatch.d.ts +29 -0
- package/extras/keymap/services/layers.d.ts +34 -0
- package/extras/keymap/services/notify.d.ts +18 -0
- package/extras/keymap/services/projection.d.ts +61 -0
- package/extras/keymap/services/runtime.d.ts +15 -0
- package/extras/keymap/services/state.d.ts +100 -0
- package/extras/keymap/types.d.ts +446 -0
- package/extras.d.ts +1 -0
- package/extras.js +4493 -0
- package/extras.js.map +38 -0
- package/{index-rgnbg53q.js → index-12r7mj9c.js} +3 -3
- package/index-d98zh563.js +489 -0
- package/index-d98zh563.js.map +11 -0
- package/{index-z2gnvv84.js → index-hhfy0q0n.js} +50 -20
- package/{index-z2gnvv84.js.map → index-hhfy0q0n.js.map} +8 -8
- package/{index-1j5hqa8e.js → index-p2m75ex9.js} +11 -472
- package/{index-1j5hqa8e.js.map → index-p2m75ex9.js.map} +6 -8
- package/index.js +10 -6
- package/index.js.map +1 -1
- package/package.json +12 -7
- package/renderables/Select.d.ts +3 -1
- package/renderables/TabSelect.d.ts +3 -1
- package/renderables/Textarea.d.ts +5 -3
- package/renderer.d.ts +9 -0
- package/runtime-plugin-support.js +5 -4
- package/runtime-plugin-support.js.map +2 -2
- package/runtime-plugin.js +5 -4
- package/runtime-plugin.js.map +1 -1
- package/testing.js +1 -1
- package/types.d.ts +3 -0
- /package/{index-rgnbg53q.js.map → index-12r7mj9c.js.map} +0 -0
- /package/lib/{keymapping.d.ts → keybinding.internal.d.ts} +0 -0
package/3d.js
CHANGED
package/Renderable.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare enum LayoutEvents {
|
|
|
16
16
|
}
|
|
17
17
|
export declare enum RenderableEvents {
|
|
18
18
|
FOCUSED = "focused",
|
|
19
|
-
BLURRED = "blurred"
|
|
19
|
+
BLURRED = "blurred",
|
|
20
|
+
DESTROYED = "destroyed"
|
|
20
21
|
}
|
|
21
22
|
export interface Position {
|
|
22
23
|
top?: number | "auto" | `${number}%`;
|
|
@@ -158,6 +159,7 @@ export declare abstract class Renderable extends BaseRenderable {
|
|
|
158
159
|
private childrenPrimarySortDirty;
|
|
159
160
|
private childrenSortedByPrimaryAxis;
|
|
160
161
|
private _shouldUpdateBefore;
|
|
162
|
+
private _lastLayoutFrame;
|
|
161
163
|
onLifecyclePass: (() => void) | null;
|
|
162
164
|
renderBefore?: (this: Renderable, buffer: OptimizedBuffer, deltaTime: number) => void;
|
|
163
165
|
renderAfter?: (this: Renderable, buffer: OptimizedBuffer, deltaTime: number) => void;
|
package/console.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { ColorInput } from "./lib/RGBA.js";
|
|
|
4
4
|
import { OptimizedBuffer } from "./buffer.js";
|
|
5
5
|
import { type Clock } from "./lib/clock.js";
|
|
6
6
|
import { Capture } from "./lib/output.capture.js";
|
|
7
|
-
import { type KeyBinding as BaseKeyBinding
|
|
7
|
+
import { type KeyBinding as BaseKeyBinding } from "./lib/keybinding.internal.js";
|
|
8
|
+
type KeyAliasMap = Record<string, string>;
|
|
8
9
|
export declare const capture: Capture;
|
|
9
10
|
export declare enum ConsolePosition {
|
|
10
11
|
TOP = "top",
|
|
@@ -142,3 +143,4 @@ export declare class TerminalConsole extends EventEmitter {
|
|
|
142
143
|
};
|
|
143
144
|
private saveLogsToFile;
|
|
144
145
|
}
|
|
146
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./keymap/index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Keymap } from "../types.js";
|
|
2
|
+
export interface BackspacePopsPendingSequenceOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true, consume Backspace after popping the sequence so it does not
|
|
5
|
+
* reach the focused renderable or lower-priority listeners. Default: `true`.
|
|
6
|
+
*/
|
|
7
|
+
preventDefault?: boolean;
|
|
8
|
+
priority?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function registerBackspacePopsPendingSequence(keymap: Keymap, options?: BackspacePopsPendingSequenceOptions): () => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BindingInput, Bindings, Layer, Keymap } from "../types.js";
|
|
2
|
+
declare const editBufferCommandNames: readonly ["move-left", "move-right", "move-up", "move-down", "select-left", "select-right", "select-up", "select-down", "line-home", "line-end", "select-line-home", "select-line-end", "visual-line-home", "visual-line-end", "select-visual-line-home", "select-visual-line-end", "buffer-home", "buffer-end", "select-buffer-home", "select-buffer-end", "delete-line", "delete-to-line-end", "delete-to-line-start", "backspace", "delete", "newline", "undo", "redo", "word-forward", "word-backward", "select-word-forward", "select-word-backward", "delete-word-forward", "delete-word-backward", "select-all", "submit"];
|
|
3
|
+
export type EditBufferCommandName = (typeof editBufferCommandNames)[number];
|
|
4
|
+
export interface EditBufferCommandOptions {
|
|
5
|
+
descriptions?: Partial<Record<EditBufferCommandName, string>>;
|
|
6
|
+
}
|
|
7
|
+
export type ManagedTextareaLayer = Omit<Layer, "bindings"> & {
|
|
8
|
+
bindings?: Bindings;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Returns the default textarea bindings with any overrides prepended so they
|
|
12
|
+
* take precedence. Prefer `registerManagedTextareaLayer` unless you are
|
|
13
|
+
* composing a custom textarea integration.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createTextareaBindings(overrides?: readonly BindingInput[]): BindingInput[];
|
|
16
|
+
/**
|
|
17
|
+
* Suspends a focused `TextareaRenderable`'s own key handling so keymap
|
|
18
|
+
* bindings can take over, restoring the previous suspend state on cleanup or
|
|
19
|
+
* focus change. Reference-counted per `Keymap`; prefer
|
|
20
|
+
* `registerManagedTextareaLayer` unless you need this separately.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerTextareaMappingSuspension(keymap: Keymap): () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Registers the standard edit-buffer commands against
|
|
25
|
+
* `renderer.currentFocusedEditor`. Reference-counted per `Keymap`; prefer
|
|
26
|
+
* `registerManagedTextareaLayer` unless you need the commands without the
|
|
27
|
+
* default bindings or textarea suspension.
|
|
28
|
+
*/
|
|
29
|
+
export declare function registerEditBufferCommands(keymap: Keymap, options?: EditBufferCommandOptions): () => void;
|
|
30
|
+
/**
|
|
31
|
+
* High-level textarea integration: registers the edit-buffer commands,
|
|
32
|
+
* suspends the textarea's built-in key handling while focused, and installs
|
|
33
|
+
* the layer with default bindings plus overrides. Safe to combine with the
|
|
34
|
+
* lower-level helpers because they are reference-counted.
|
|
35
|
+
*/
|
|
36
|
+
export declare function registerManagedTextareaLayer(keymap: Keymap, layer: ManagedTextareaLayer, options?: EditBufferCommandOptions): () => void;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Keymap, ReactiveMatcher } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Accepted `enabled` values: boolean, raw `() => boolean`, or an
|
|
4
|
+
* `ReactiveMatcher` for subscription-driven invalidation.
|
|
5
|
+
*/
|
|
6
|
+
export type Enabled = boolean | (() => boolean) | ReactiveMatcher;
|
|
7
|
+
export declare function registerEnabledField(keymap: Keymap): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Keymap } from "../types.js";
|
|
2
|
+
export interface EscapeClearsPendingSequenceOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true, consume Escape after clearing the sequence so it does not
|
|
5
|
+
* reach the focused renderable or lower-priority listeners. Default: `true`.
|
|
6
|
+
*/
|
|
7
|
+
preventDefault?: boolean;
|
|
8
|
+
priority?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function registerEscapeClearsPendingSequence(keymap: Keymap, options?: EscapeClearsPendingSequenceOptions): () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandContext, Keymap } from "../types.js";
|
|
2
|
+
export interface ExCommand {
|
|
3
|
+
name: string;
|
|
4
|
+
aliases?: string[];
|
|
5
|
+
nargs?: "0" | "1" | "?" | "*" | "+";
|
|
6
|
+
run: (ctx: CommandContext & {
|
|
7
|
+
raw: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
}) => void | Promise<void>;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function registerExCommands(keymap: Keymap, commands: ExCommand[]): () => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { registerAliasesField } from "./aliases.js";
|
|
2
|
+
export { registerBaseLayoutFallback } from "./base-layout.js";
|
|
3
|
+
export { registerBackspacePopsPendingSequence } from "./backspace-pops-pending-sequence.js";
|
|
4
|
+
export { registerCommaBindings } from "./comma-bindings.js";
|
|
5
|
+
export { registerDeadBindingWarnings } from "./dead-bindings.js";
|
|
6
|
+
export { registerEscapeClearsPendingSequence } from "./escape-clears-pending-sequence.js";
|
|
7
|
+
export { registerEnabledField } from "./enabled.js";
|
|
8
|
+
export { registerEmacsBindings } from "./emacs-bindings.js";
|
|
9
|
+
export { registerExCommands } from "./ex-commands.js";
|
|
10
|
+
export { createTextareaBindings, registerEditBufferCommands, registerManagedTextareaLayer, registerTextareaMappingSuspension, } from "./edit-buffer-bindings.js";
|
|
11
|
+
export { registerLeader } from "./leader.js";
|
|
12
|
+
export { registerMetadataFields } from "./metadata.js";
|
|
13
|
+
export { registerTimedLeader } from "./timed-leader.js";
|
|
14
|
+
export type { Aliases } from "./aliases.js";
|
|
15
|
+
export type { BackspacePopsPendingSequenceOptions } from "./backspace-pops-pending-sequence.js";
|
|
16
|
+
export type { EscapeClearsPendingSequenceOptions } from "./escape-clears-pending-sequence.js";
|
|
17
|
+
export type { Enabled } from "./enabled.js";
|
|
18
|
+
export type { ExCommand } from "./ex-commands.js";
|
|
19
|
+
export type { EditBufferCommandName, EditBufferCommandOptions, ManagedTextareaLayer } from "./edit-buffer-bindings.js";
|
|
20
|
+
export type { LeaderOptions } from "./leader.js";
|
|
21
|
+
export type { TimedLeaderOptions } from "./timed-leader.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Keymap } from "../types.js";
|
|
2
|
+
import { type LeaderOptions } from "./leader.js";
|
|
3
|
+
export interface TimedLeaderOptions extends LeaderOptions {
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
onArm?: () => void;
|
|
6
|
+
onDisarm?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function registerTimedLeader(keymap: Keymap, options: TimedLeaderOptions): () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getKeymap, Keymap } from "./keymap.js";
|
|
2
|
+
export { defaultBindingParser, defaultBindingSyntax, defaultEventMatchResolver, parseKeySequenceLike, } from "./lib/default-parser.js";
|
|
3
|
+
export { namedSingleStrokeKeyNames, namedSingleStrokeKeys } from "./lib/named-keys.js";
|
|
4
|
+
export { stringifyKeySequence, stringifyKeyStroke } from "./lib/utils.js";
|
|
5
|
+
export * as addons from "./addons/index.js";
|
|
6
|
+
export type { KeyLike, ActiveBinding, KeyStringifyInput, StringifyOptions, Attributes, BindingCommand, BindingParser, BindingSyntax, BindingParserContext, BindingParserResult, BindingExpander, BindingExpanderContext, BindingEvent, BindingFieldCompiler, BindingFieldContext, BindingInput, BindingTransformer, BindingTransformerContext, ParsedBindingInput, BindingShorthand, Bindings, ActiveKey, ActiveKeyOptions, KeymapActiveKey, KeymapBindingInput, KeymapCommandDefinition, KeymapCommandRecord, Listener, ErrorEvent, CommandDefinition, CommandFilter, CommandQuery, CommandQueryValue, CommandRecord, RunCommandOptions, RunCommandResult, CommandHandler, CommandFieldCompiler, CommandFieldContext, CommandContext, CommandResolver, CommandResolverContext, CommandResult, EventData, KeyInputContext, FocusLayer, FocusWithinLayer, GlobalLayer, LayerAnalysisContext, LayerAnalyzer, LayerFieldCompiler, LayerFieldContext, LayerFields, Layer, EventName, Events, InterceptName, Intercepts, KeyInterceptOptions, ParsedCommand, RawInterceptOptions, RawInputContext, ReactiveMatcher, UnresolvedCommandContext, WarningEvent, ResolvedBindingCommand, Scope, EventMatchResolverContext, EventMatchResolver, TargetLayer, KeyToken, ResolvedKeyToken, KeySequencePart, NormalizedKeyStroke, KeyStrokeInput, } from "./types.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type CliRenderer } from "../../renderer.js";
|
|
2
|
+
import type { ActiveKey, ActiveKeyOptions, BindingInput, BindingExpander, BindingParser, BindingSyntax, BindingFieldCompiler, Bindings, BindingTransformer, Events, CommandFieldCompiler, CommandQuery, CommandRecord, LayerAnalyzer, Listener, RunCommandOptions, RunCommandResult, CommandResolver, KeyInterceptOptions, KeyInputContext, Layer, LayerFieldCompiler, RawInterceptOptions, RawInputContext, EventMatchResolver, KeyStringifyInput, KeyToken, KeyLike, KeySequencePart } from "./types.js";
|
|
3
|
+
export declare class Keymap {
|
|
4
|
+
readonly renderer: CliRenderer;
|
|
5
|
+
private readonly state;
|
|
6
|
+
private cleanedUp;
|
|
7
|
+
private readonly resources;
|
|
8
|
+
private events;
|
|
9
|
+
private hooks;
|
|
10
|
+
private readonly notify;
|
|
11
|
+
private readonly runtime;
|
|
12
|
+
private readonly conditions;
|
|
13
|
+
private readonly commands;
|
|
14
|
+
private readonly projection;
|
|
15
|
+
private readonly compiler;
|
|
16
|
+
private readonly dispatch;
|
|
17
|
+
private readonly layers;
|
|
18
|
+
private readonly keypressListener;
|
|
19
|
+
private readonly keyreleaseListener;
|
|
20
|
+
private readonly rawListener;
|
|
21
|
+
private readonly focusedRenderableListener;
|
|
22
|
+
constructor(renderer: CliRenderer);
|
|
23
|
+
private cleanup;
|
|
24
|
+
setData(name: string, value: unknown): void;
|
|
25
|
+
getData(name: string): unknown;
|
|
26
|
+
hasPendingSequence(): boolean;
|
|
27
|
+
getPendingSequence(): readonly KeySequencePart[];
|
|
28
|
+
createKeyMatcher(key: KeyLike): (input: KeyStringifyInput | null | undefined) => boolean;
|
|
29
|
+
clearPendingSequence(): void;
|
|
30
|
+
popPendingSequence(): boolean;
|
|
31
|
+
getActiveKeys(options?: ActiveKeyOptions): readonly ActiveKey[];
|
|
32
|
+
getCommands(query?: CommandQuery): readonly CommandRecord[];
|
|
33
|
+
normalizeCommandName(name: string): string;
|
|
34
|
+
normalizeBindings(bindings: Bindings): BindingInput[];
|
|
35
|
+
acquireResource(key: symbol, setup: () => () => void): () => void;
|
|
36
|
+
runCommand(cmd: string, options?: RunCommandOptions): RunCommandResult;
|
|
37
|
+
on(name: "state", fn: Listener<Events["state"]>): () => void;
|
|
38
|
+
on(name: "pendingSequence", fn: Listener<Events["pendingSequence"]>): () => void;
|
|
39
|
+
on(name: "unresolvedCommand", fn: Listener<Events["unresolvedCommand"]>): () => void;
|
|
40
|
+
on(name: "warning", fn: Listener<Events["warning"]>): () => void;
|
|
41
|
+
on(name: "error", fn: Listener<Events["error"]>): () => void;
|
|
42
|
+
intercept(name: "key", fn: (ctx: KeyInputContext) => void, options?: KeyInterceptOptions): () => void;
|
|
43
|
+
intercept(name: "raw", fn: (ctx: RawInputContext) => void, options?: RawInterceptOptions): () => void;
|
|
44
|
+
registerLayer(layer: Layer): () => void;
|
|
45
|
+
registerLayerFields(fields: Record<string, LayerFieldCompiler>): () => void;
|
|
46
|
+
prependBindingTransformer(transformer: BindingTransformer): () => void;
|
|
47
|
+
appendBindingTransformer(transformer: BindingTransformer): () => void;
|
|
48
|
+
clearBindingTransformers(): void;
|
|
49
|
+
prependBindingParser(parser: BindingParser): () => void;
|
|
50
|
+
appendBindingParser(parser: BindingParser): () => void;
|
|
51
|
+
clearBindingParsers(): void;
|
|
52
|
+
setBindingSyntax(syntax: BindingSyntax): void;
|
|
53
|
+
clearBindingSyntax(): 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): () => void;
|
|
61
|
+
appendCommandResolver(resolver: CommandResolver): () => void;
|
|
62
|
+
clearCommandResolvers(): void;
|
|
63
|
+
prependLayerAnalyzer(analyzer: LayerAnalyzer): () => void;
|
|
64
|
+
appendLayerAnalyzer(analyzer: LayerAnalyzer): () => void;
|
|
65
|
+
clearLayerAnalyzers(): void;
|
|
66
|
+
prependEventMatchResolver(resolver: EventMatchResolver): () => void;
|
|
67
|
+
appendEventMatchResolver(resolver: EventMatchResolver): () => void;
|
|
68
|
+
clearEventMatchResolvers(): void;
|
|
69
|
+
private handleFocusedRenderableChange;
|
|
70
|
+
private runWithStateChangeBatch;
|
|
71
|
+
private queueStateChange;
|
|
72
|
+
private emitError;
|
|
73
|
+
private applyTokenState;
|
|
74
|
+
private warnOnce;
|
|
75
|
+
private warnUnknownField;
|
|
76
|
+
private warnUnknownToken;
|
|
77
|
+
private releaseResource;
|
|
78
|
+
}
|
|
79
|
+
export declare function getKeymap(renderer: CliRenderer): Keymap;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BindingParser, BindingSyntax, EventMatchResolver, KeyLike, KeySequencePart, ResolvedKeyToken, NormalizedKeyStroke } from "../types.js";
|
|
2
|
+
export declare const defaultBindingSyntax: BindingSyntax;
|
|
3
|
+
export declare const defaultBindingParser: BindingParser;
|
|
4
|
+
export declare function parseKeyLike(key: KeyLike, extraNames?: ReadonlySet<string>): NormalizedKeyStroke;
|
|
5
|
+
export declare function parseKeySequenceLike(key: KeyLike, tokens?: ReadonlyMap<string, ResolvedKeyToken>, extraNames?: ReadonlySet<string>): KeySequencePart[];
|
|
6
|
+
export declare const defaultEventMatchResolver: EventMatchResolver;
|
|
@@ -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,2 @@
|
|
|
1
|
+
export declare const namedSingleStrokeKeyNames: readonly ["space", "tab", "linefeed", "return", "escape", "backspace", "delete", "insert", "home", "end", "pageup", "pagedown", "left", "right", "up", "down", "kp0", "kp1", "kp2", "kp3", "kp4", "kp5", "kp6", "kp7", "kp8", "kp9", "kpdecimal", "kpdivide", "kpmultiply", "kpminus", "kpplus", "kpenter", "kpequal", "kpseparator", "kpleft", "kpright", "kpup", "kpdown", "kppageup", "kppagedown", "kphome", "kpend", "kpinsert", "kpdelete", "clear", ...string[]];
|
|
2
|
+
export declare const namedSingleStrokeKeys: Set<string>;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { KeyEvent } from "../../../lib/KeyHandler.js";
|
|
2
|
+
import type { Attributes, BindingCommand, BindingInput, Bindings, CommandRecord, EventData, KeyStrokeInput, KeySequencePart, ParsedBindingInput, NormalizedKeyStroke, RegisteredCommand, ResolvedBindingCommand, SequenceNode, KeyStringifyInput, StringifyOptions } from "../types.js";
|
|
3
|
+
export interface SnapshotDataValueOptions {
|
|
4
|
+
deep?: boolean;
|
|
5
|
+
freeze?: boolean;
|
|
6
|
+
preserveNonPlainObjects?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const SNAPSHOT_COMMAND_METADATA_OPTIONS: Readonly<{
|
|
9
|
+
deep: true;
|
|
10
|
+
preserveNonPlainObjects: true;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const SNAPSHOT_FROZEN_COMMAND_METADATA_OPTIONS: Readonly<{
|
|
13
|
+
deep: true;
|
|
14
|
+
freeze: true;
|
|
15
|
+
preserveNonPlainObjects: true;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const EMPTY_COMMAND_FIELDS: Readonly<Record<string, unknown>>;
|
|
18
|
+
export declare function normalizeKeyName(name: string): string;
|
|
19
|
+
export declare function snapshotStroke(stroke: NormalizedKeyStroke): NormalizedKeyStroke;
|
|
20
|
+
export declare function isPromiseLike(value: unknown): value is Promise<unknown>;
|
|
21
|
+
export declare function getErrorMessage(error: unknown, fallback: string): string;
|
|
22
|
+
export declare function snapshotDataValue(value: unknown, options?: SnapshotDataValueOptions): unknown;
|
|
23
|
+
export declare function sortByPriorityAndOrder<T extends {
|
|
24
|
+
priority: number;
|
|
25
|
+
order: number;
|
|
26
|
+
}>(items: T[], options?: {
|
|
27
|
+
order?: "asc" | "desc";
|
|
28
|
+
}): T[];
|
|
29
|
+
export declare function buildBindingKey(stroke: NormalizedKeyStroke): string;
|
|
30
|
+
export declare function createSequenceNode(parent: SequenceNode | null, stroke: NormalizedKeyStroke | null, matchKey: string | null): SequenceNode;
|
|
31
|
+
export declare function mergeRequirement(target: EventData, name: string, value: unknown, source: string): void;
|
|
32
|
+
export declare function mergeAttribute(target: Attributes, name: string, value: unknown, source: string): void;
|
|
33
|
+
export declare function snapshotAttributes(attrs: Attributes): Readonly<Attributes> | undefined;
|
|
34
|
+
export declare function snapshotBindingInput(binding: BindingInput): BindingInput;
|
|
35
|
+
export declare function snapshotParsedBindingInput(binding: ParsedBindingInput): ParsedBindingInput;
|
|
36
|
+
export declare function normalizeBindingCommand(command: BindingCommand | undefined): BindingCommand | undefined;
|
|
37
|
+
export declare function snapshotBindingInputs(bindings: Bindings): BindingInput[];
|
|
38
|
+
export declare function createParsedKeyPart(stroke: NormalizedKeyStroke, display?: string, matchKey?: string): KeySequencePart;
|
|
39
|
+
export declare function stringifyKeyStroke(input: KeyStringifyInput, options?: StringifyOptions): string;
|
|
40
|
+
export declare function stringifyKeySequence(input: readonly KeyStringifyInput[], options?: StringifyOptions): string;
|
|
41
|
+
export declare function normalizeKeyStroke(input: KeyStrokeInput): NormalizedKeyStroke;
|
|
42
|
+
export declare function normalizeEventKeyStroke(event: KeyEvent): NormalizedKeyStroke;
|
|
43
|
+
export declare function normalizeCommandName(name: string): string;
|
|
44
|
+
export declare function getRegisteredCommandRecord(command: RegisteredCommand): CommandRecord;
|
|
45
|
+
export declare function resolveRegisteredCommand(command: RegisteredCommand, options?: {
|
|
46
|
+
includeRecord?: boolean;
|
|
47
|
+
}): ResolvedBindingCommand;
|
|
48
|
+
export declare function normalizeBindingInputs(bindings: Bindings): BindingInput[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Renderable } from "../../../Renderable.js";
|
|
2
|
+
import { KeyEvent } from "../../../lib/KeyHandler.js";
|
|
3
|
+
import type { Keymap } from "../keymap.js";
|
|
4
|
+
import type { Emitter } from "../lib/emitter.js";
|
|
5
|
+
import type { CommandDefinition, CommandResolver, CompiledBinding, Hooks, RegisteredCommand, RegisteredLayer, ResolvedBindingCommand, RunCommandOptions, RunCommandResult } from "../types.js";
|
|
6
|
+
import type { NotificationService } from "./notify.js";
|
|
7
|
+
import type { ProjectionService } from "./projection.js";
|
|
8
|
+
import type { RuntimeService } from "./runtime.js";
|
|
9
|
+
import type { State } from "./state.js";
|
|
10
|
+
interface ResolvedCommandLookup {
|
|
11
|
+
resolved?: ResolvedBindingCommand;
|
|
12
|
+
hadError: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface CommandsOptions {
|
|
15
|
+
keymap: Keymap;
|
|
16
|
+
}
|
|
17
|
+
export declare class CommandService {
|
|
18
|
+
private readonly state;
|
|
19
|
+
private readonly notify;
|
|
20
|
+
private readonly runtime;
|
|
21
|
+
private readonly projection;
|
|
22
|
+
private readonly hooks;
|
|
23
|
+
private readonly options;
|
|
24
|
+
constructor(state: State, notify: NotificationService, runtime: RuntimeService, projection: ProjectionService, hooks: Emitter<Hooks>, options: CommandsOptions);
|
|
25
|
+
normalizeCommandName(name: string): string;
|
|
26
|
+
normalizeCommands(commands: readonly CommandDefinition[]): RegisteredCommand[];
|
|
27
|
+
prependCommandResolver(resolver: CommandResolver): () => void;
|
|
28
|
+
appendCommandResolver(resolver: CommandResolver): () => void;
|
|
29
|
+
clearCommandResolvers(): void;
|
|
30
|
+
private mutateCommandResolvers;
|
|
31
|
+
runCommand(cmd: string, options?: RunCommandOptions): RunCommandResult;
|
|
32
|
+
runBinding(bindingLayer: RegisteredLayer, binding: CompiledBinding, event: KeyEvent, focused: Renderable | null): boolean;
|
|
33
|
+
warnIfBindingCommandIsCurrentlyUnresolved(binding: CompiledBinding, layerCommands?: ReadonlyMap<string, RegisteredCommand>): void;
|
|
34
|
+
private hasRegisteredCommand;
|
|
35
|
+
resolveCommandWithResolvers(command: string, focused: Renderable | null, options?: {
|
|
36
|
+
includeRecord?: boolean;
|
|
37
|
+
}): ResolvedCommandLookup;
|
|
38
|
+
private createCommandResolverContext;
|
|
39
|
+
private executeResolvedCommand;
|
|
40
|
+
private handleUnresolvedCommand;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Renderable } from "../../../Renderable.js";
|
|
2
|
+
import type { CommandService } from "./commands.js";
|
|
3
|
+
import type { ConditionService } from "./conditions.js";
|
|
4
|
+
import type { State } from "./state.js";
|
|
5
|
+
import type { NotificationService } from "./notify.js";
|
|
6
|
+
import type { BindingInput, RegisteredCommand, Scope, CompiledBindingsResult, KeyLike, KeySequencePart, ResolvedKeyToken } from "../types.js";
|
|
7
|
+
export interface CompilerOptions {
|
|
8
|
+
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
9
|
+
warnUnknownToken: (token: string, sequence: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare class CompilerService {
|
|
12
|
+
private readonly state;
|
|
13
|
+
private readonly notify;
|
|
14
|
+
private readonly commands;
|
|
15
|
+
private readonly conditions;
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(state: State, notify: NotificationService, commands: CommandService, conditions: ConditionService, options: CompilerOptions);
|
|
18
|
+
normalizeTokenName(token: string): string;
|
|
19
|
+
parseTokenKey(key: KeyLike): KeySequencePart;
|
|
20
|
+
compileBindings(bindings: readonly BindingInput[], tokens: ReadonlyMap<string, ResolvedKeyToken>, sourceScope: Scope, sourceTarget: Renderable | undefined, sourceLayerOrder: number, compileFields?: Readonly<Record<string, unknown>>, commandLookup?: ReadonlyMap<string, RegisteredCommand>): CompiledBindingsResult;
|
|
21
|
+
private getBindingSyntax;
|
|
22
|
+
private parseObjectKeyPart;
|
|
23
|
+
private normalizeBindingEvent;
|
|
24
|
+
private applyBindingTransformers;
|
|
25
|
+
private insertBinding;
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NotificationService } from "./notify.js";
|
|
2
|
+
import type { State } from "./state.js";
|
|
3
|
+
import type { ReactiveMatcher, RegisteredLayer, RuntimeMatchable, RuntimeMatcher } from "../types.js";
|
|
4
|
+
export declare class ConditionService {
|
|
5
|
+
private readonly state;
|
|
6
|
+
private readonly notify;
|
|
7
|
+
constructor(state: State, notify: NotificationService);
|
|
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): boolean;
|
|
15
|
+
private matchRequirements;
|
|
16
|
+
private hasFreshConditionCache;
|
|
17
|
+
private updateConditionCache;
|
|
18
|
+
private matchesRuntimeMatcher;
|
|
19
|
+
private matchesRuntimeMatchers;
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { KeyEvent } from "../../../lib/KeyHandler.js";
|
|
2
|
+
import type { CompilerService } from "./compiler.js";
|
|
3
|
+
import type { CommandService } from "./commands.js";
|
|
4
|
+
import type { ConditionService } from "./conditions.js";
|
|
5
|
+
import type { NotificationService } from "./notify.js";
|
|
6
|
+
import type { ProjectionService } from "./projection.js";
|
|
7
|
+
import type { RuntimeService } from "./runtime.js";
|
|
8
|
+
import type { State } from "./state.js";
|
|
9
|
+
export declare class DispatchService {
|
|
10
|
+
private readonly state;
|
|
11
|
+
private readonly notify;
|
|
12
|
+
private readonly runtime;
|
|
13
|
+
private readonly projection;
|
|
14
|
+
private readonly conditions;
|
|
15
|
+
private readonly commands;
|
|
16
|
+
private readonly compiler;
|
|
17
|
+
private readonly eventMatchResolverContext;
|
|
18
|
+
constructor(state: State, notify: NotificationService, runtime: RuntimeService, projection: ProjectionService, conditions: ConditionService, commands: CommandService, compiler: CompilerService);
|
|
19
|
+
handleRawSequence(sequence: string): boolean;
|
|
20
|
+
handleKeyEvent(event: KeyEvent, release: boolean): void;
|
|
21
|
+
private dispatchReleaseLayers;
|
|
22
|
+
private dispatchLayers;
|
|
23
|
+
private dispatchPendingSequence;
|
|
24
|
+
private dispatchFromRoot;
|
|
25
|
+
private resolveEventMatchKeys;
|
|
26
|
+
private runReleaseBindings;
|
|
27
|
+
private getReachableChild;
|
|
28
|
+
private runBindings;
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Renderable } from "../../../Renderable.js";
|
|
2
|
+
import type { CompilerService } from "./compiler.js";
|
|
3
|
+
import type { CommandService } from "./commands.js";
|
|
4
|
+
import type { ConditionService } from "./conditions.js";
|
|
5
|
+
import type { ProjectionService } from "./projection.js";
|
|
6
|
+
import type { Layer, ResolvedKeyToken } from "../types.js";
|
|
7
|
+
import type { State } from "./state.js";
|
|
8
|
+
import type { NotificationService } from "./notify.js";
|
|
9
|
+
interface LayersOptions {
|
|
10
|
+
compiler: CompilerService;
|
|
11
|
+
commands: CommandService;
|
|
12
|
+
rootTarget: Renderable;
|
|
13
|
+
warnUnknownField: (kind: "binding" | "layer", fieldName: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class LayerService {
|
|
16
|
+
private readonly state;
|
|
17
|
+
private readonly notify;
|
|
18
|
+
private readonly conditions;
|
|
19
|
+
private readonly projection;
|
|
20
|
+
private readonly options;
|
|
21
|
+
constructor(state: State, notify: NotificationService, conditions: ConditionService, projection: ProjectionService, options: LayersOptions);
|
|
22
|
+
registerLayer(layer: Layer): () => void;
|
|
23
|
+
applyTokenState(nextTokens: Map<string, ResolvedKeyToken>): void;
|
|
24
|
+
private normalizeScope;
|
|
25
|
+
private resolveIndexTarget;
|
|
26
|
+
private createCommands;
|
|
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 } from "../types.js";
|
|
2
|
+
import type { State } from "./state.js";
|
|
3
|
+
import { Emitter } from "../lib/emitter.js";
|
|
4
|
+
type DiagnosticEvents = Pick<Events, "warning" | "error">;
|
|
5
|
+
export declare class NotificationService {
|
|
6
|
+
private readonly state;
|
|
7
|
+
private readonly events;
|
|
8
|
+
private readonly hooks;
|
|
9
|
+
constructor(state: State, events: Emitter<DiagnosticEvents>, hooks: Emitter<Hooks>);
|
|
10
|
+
runWithStateChangeBatch<T>(fn: () => T): T;
|
|
11
|
+
queueStateChange(): void;
|
|
12
|
+
emitWarning(message: string): void;
|
|
13
|
+
emitError(message: string, cause?: unknown): void;
|
|
14
|
+
reportListenerError(name: HookName, error: unknown): void;
|
|
15
|
+
warnOnce(key: string, message: string): void;
|
|
16
|
+
private flushStateChange;
|
|
17
|
+
}
|
|
18
|
+
export {};
|