@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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/extras/binding-sections.ts
|
|
3
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
4
|
+
function isObject(value) {
|
|
5
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function isKeyLike(value) {
|
|
8
|
+
return typeof value === "string" || isObject(value);
|
|
9
|
+
}
|
|
10
|
+
function cloneKeyLike(key) {
|
|
11
|
+
if (typeof key === "string") {
|
|
12
|
+
return key;
|
|
13
|
+
}
|
|
14
|
+
return { ...key };
|
|
15
|
+
}
|
|
16
|
+
function invalidBindingValue(section, command, index) {
|
|
17
|
+
const location = index === undefined ? `"${section}.${command}"` : `"${section}.${command}" at index ${index}`;
|
|
18
|
+
return new Error(`Invalid binding value for ${location}: expected false, a key, a binding object, or an array of keys/binding objects`);
|
|
19
|
+
}
|
|
20
|
+
function resolveBindingItem(section, command, item, index) {
|
|
21
|
+
if (!isKeyLike(item)) {
|
|
22
|
+
throw invalidBindingValue(section, command, index);
|
|
23
|
+
}
|
|
24
|
+
if (typeof item === "string" || !("key" in item)) {
|
|
25
|
+
return {
|
|
26
|
+
key: cloneKeyLike(item),
|
|
27
|
+
cmd: command
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const key = item.key;
|
|
31
|
+
if (!isKeyLike(key)) {
|
|
32
|
+
throw invalidBindingValue(section, command, index);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
...item,
|
|
36
|
+
key: cloneKeyLike(key),
|
|
37
|
+
cmd: command
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveBindingValue(section, command, value) {
|
|
41
|
+
if (value === false || value === "none") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
if (value.length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const items = value;
|
|
49
|
+
const bindings = new Array(items.length);
|
|
50
|
+
for (let index = 0;index < items.length; index += 1) {
|
|
51
|
+
bindings[index] = resolveBindingItem(section, command, items[index], index);
|
|
52
|
+
}
|
|
53
|
+
return bindings;
|
|
54
|
+
}
|
|
55
|
+
return [resolveBindingItem(section, command, value)];
|
|
56
|
+
}
|
|
57
|
+
function resolveBindingSections(config, options) {
|
|
58
|
+
const sections = {};
|
|
59
|
+
const lookups = new Map;
|
|
60
|
+
for (const section of options?.sections ?? []) {
|
|
61
|
+
sections[section] = [];
|
|
62
|
+
lookups.set(section, new Map);
|
|
63
|
+
}
|
|
64
|
+
for (const section in config) {
|
|
65
|
+
if (!hasOwn.call(config, section)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const sectionConfig = config[section];
|
|
69
|
+
if (!isObject(sectionConfig)) {
|
|
70
|
+
throw new Error(`Invalid binding section "${section}": expected an object`);
|
|
71
|
+
}
|
|
72
|
+
const sectionLookup = new Map;
|
|
73
|
+
for (const rawCommand in sectionConfig) {
|
|
74
|
+
if (!hasOwn.call(sectionConfig, rawCommand)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const command = rawCommand.trim();
|
|
78
|
+
const bindings = resolveBindingValue(section, command, sectionConfig[rawCommand]);
|
|
79
|
+
if (!bindings) {
|
|
80
|
+
sectionLookup.delete(command);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
sectionLookup.set(command, bindings);
|
|
84
|
+
}
|
|
85
|
+
let sectionBindingCount = 0;
|
|
86
|
+
for (const bindings of sectionLookup.values()) {
|
|
87
|
+
sectionBindingCount += bindings.length;
|
|
88
|
+
}
|
|
89
|
+
const sectionBindings = new Array(sectionBindingCount);
|
|
90
|
+
let bindingIndex = 0;
|
|
91
|
+
for (const bindings of sectionLookup.values()) {
|
|
92
|
+
for (let index = 0;index < bindings.length; index += 1) {
|
|
93
|
+
sectionBindings[bindingIndex] = bindings[index];
|
|
94
|
+
bindingIndex += 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
sections[section] = sectionBindings;
|
|
98
|
+
lookups.set(section, sectionLookup);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
sections,
|
|
102
|
+
get(section, cmd) {
|
|
103
|
+
return lookups.get(section)?.get(cmd.trim());
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// src/extras/command-bindings.ts
|
|
108
|
+
function isCommandBindingKey(value) {
|
|
109
|
+
return typeof value === "string" || !!value && typeof value === "object" && !Array.isArray(value);
|
|
110
|
+
}
|
|
111
|
+
function commandBindings(bindings, options) {
|
|
112
|
+
const normalized = [];
|
|
113
|
+
const indexesByCommand = new Map;
|
|
114
|
+
for (const [command, key] of Object.entries(bindings)) {
|
|
115
|
+
if (!isCommandBindingKey(key)) {
|
|
116
|
+
const error = new Error(`Invalid command binding for "${command}": command bindings must map command strings to key strings or keystroke objects`);
|
|
117
|
+
options?.onError?.({
|
|
118
|
+
code: "invalid-command-binding",
|
|
119
|
+
command,
|
|
120
|
+
value: key,
|
|
121
|
+
reason: error
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const normalizedCommand = command.trim();
|
|
126
|
+
const nextBinding = {
|
|
127
|
+
key: typeof key === "string" ? key : { ...key },
|
|
128
|
+
cmd: normalizedCommand
|
|
129
|
+
};
|
|
130
|
+
const existingIndex = indexesByCommand.get(normalizedCommand);
|
|
131
|
+
if (existingIndex !== undefined) {
|
|
132
|
+
const previousBinding = normalized[existingIndex];
|
|
133
|
+
options?.onWarning?.({
|
|
134
|
+
code: "command-binding-override",
|
|
135
|
+
command: normalizedCommand,
|
|
136
|
+
previousKey: previousBinding.key,
|
|
137
|
+
nextKey: nextBinding.key
|
|
138
|
+
});
|
|
139
|
+
normalized[existingIndex] = nextBinding;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
indexesByCommand.set(normalizedCommand, normalized.length);
|
|
143
|
+
normalized.push(nextBinding);
|
|
144
|
+
}
|
|
145
|
+
return normalized;
|
|
146
|
+
}
|
|
147
|
+
// src/extras/formatting.ts
|
|
148
|
+
function formatStroke(part, options) {
|
|
149
|
+
if (part.tokenName) {
|
|
150
|
+
const tokenDisplay = options.tokenDisplay;
|
|
151
|
+
if (!tokenDisplay)
|
|
152
|
+
return part.display;
|
|
153
|
+
if (typeof tokenDisplay === "function")
|
|
154
|
+
return tokenDisplay(part.tokenName, part) ?? part.display;
|
|
155
|
+
return tokenDisplay[part.tokenName] ?? part.display;
|
|
156
|
+
}
|
|
157
|
+
if (part.patternName) {
|
|
158
|
+
const patternDisplay = options.patternDisplay;
|
|
159
|
+
if (!patternDisplay)
|
|
160
|
+
return part.display;
|
|
161
|
+
if (typeof patternDisplay === "function")
|
|
162
|
+
return patternDisplay(part.patternName, part) ?? part.display;
|
|
163
|
+
return patternDisplay[part.patternName] ?? part.display;
|
|
164
|
+
}
|
|
165
|
+
if (!options.keyNameAliases && !options.modifierAliases)
|
|
166
|
+
return part.display;
|
|
167
|
+
const stroke = part.stroke;
|
|
168
|
+
const modifierAliases = options.modifierAliases;
|
|
169
|
+
let formatted = "";
|
|
170
|
+
let pieceCount = 0;
|
|
171
|
+
if (stroke.ctrl) {
|
|
172
|
+
formatted = modifierAliases?.ctrl ?? "ctrl";
|
|
173
|
+
pieceCount = 1;
|
|
174
|
+
}
|
|
175
|
+
if (stroke.shift) {
|
|
176
|
+
const alias = modifierAliases?.shift ?? "shift";
|
|
177
|
+
formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`;
|
|
178
|
+
pieceCount += 1;
|
|
179
|
+
}
|
|
180
|
+
if (stroke.meta) {
|
|
181
|
+
const alias = modifierAliases?.meta ?? "meta";
|
|
182
|
+
formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`;
|
|
183
|
+
pieceCount += 1;
|
|
184
|
+
}
|
|
185
|
+
if (stroke.super) {
|
|
186
|
+
const alias = modifierAliases?.super ?? "super";
|
|
187
|
+
formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`;
|
|
188
|
+
pieceCount += 1;
|
|
189
|
+
}
|
|
190
|
+
if (stroke.hyper) {
|
|
191
|
+
const alias = modifierAliases?.hyper ?? "hyper";
|
|
192
|
+
formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`;
|
|
193
|
+
pieceCount += 1;
|
|
194
|
+
}
|
|
195
|
+
const name = stroke.name === "return" ? "enter" : stroke.name;
|
|
196
|
+
const keyName = options.keyNameAliases?.[name] ?? name;
|
|
197
|
+
return pieceCount === 0 ? keyName : `${formatted}+${keyName}`;
|
|
198
|
+
}
|
|
199
|
+
function formatKeySequence(parts, options = {}) {
|
|
200
|
+
if (!parts || parts.length === 0)
|
|
201
|
+
return "";
|
|
202
|
+
const separator = options.separator ?? " ";
|
|
203
|
+
let formatted = formatStroke(parts[0], options);
|
|
204
|
+
for (let index = 1;index < parts.length; index += 1) {
|
|
205
|
+
formatted += separator + formatStroke(parts[index], options);
|
|
206
|
+
}
|
|
207
|
+
return formatted;
|
|
208
|
+
}
|
|
209
|
+
function formatCommandBindings(bindings, options = {}) {
|
|
210
|
+
if (!bindings?.length)
|
|
211
|
+
return;
|
|
212
|
+
const bindingSeparator = options.bindingSeparator ?? ", ";
|
|
213
|
+
const dedupe = options.dedupe !== false;
|
|
214
|
+
const seen = dedupe ? new Set : undefined;
|
|
215
|
+
let formatted = "";
|
|
216
|
+
let itemCount = 0;
|
|
217
|
+
for (const binding of bindings) {
|
|
218
|
+
const item = formatKeySequence(binding.sequence, options);
|
|
219
|
+
if (!item)
|
|
220
|
+
continue;
|
|
221
|
+
if (seen) {
|
|
222
|
+
if (seen.has(item))
|
|
223
|
+
continue;
|
|
224
|
+
seen.add(item);
|
|
225
|
+
}
|
|
226
|
+
formatted = itemCount === 0 ? item : `${formatted}${bindingSeparator}${item}`;
|
|
227
|
+
itemCount += 1;
|
|
228
|
+
}
|
|
229
|
+
return formatted;
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
resolveBindingSections,
|
|
233
|
+
formatKeySequence,
|
|
234
|
+
formatCommandBindings,
|
|
235
|
+
commandBindings
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
//# debugId=7BE7E370039A4BC264756E2164756E21
|
|
239
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/extras/binding-sections.ts", "../src/extras/command-bindings.ts", "../src/extras/formatting.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// Opinionated config-to-keymap transformation helper. Treat this as one\n// practical shape you can copy and adjust for application-specific needs.\nimport type { Binding, KeyLike, KeymapEvent } from \"../types.js\"\n\nexport type BindingSectionItem<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> =\n | KeyLike\n | Binding<TTarget, TEvent>\n\nexport type BindingValue<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> =\n | false\n | \"none\"\n | BindingSectionItem<TTarget, TEvent>\n | readonly BindingSectionItem<TTarget, TEvent>[]\n\nexport type BindingSectionConfig<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = Readonly<\n Record<string, BindingValue<TTarget, TEvent>>\n>\n\nexport type BindingSectionsConfig<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = Readonly<\n Record<string, BindingSectionConfig<TTarget, TEvent>>\n>\n\ntype LiteralStringKeys<T> = string extends Extract<keyof T, string> ? never : Extract<keyof T, string>\n\nconst hasOwn = Object.prototype.hasOwnProperty\n\nexport interface ResolvedBindingSections<\n TTarget extends object = object,\n TEvent extends KeymapEvent = KeymapEvent,\n TSection extends string = string,\n> {\n sections: Record<TSection, Binding<TTarget, TEvent>[]>\n get(section: string, cmd: string): readonly Binding<TTarget, TEvent>[] | undefined\n}\n\nexport interface ResolveBindingSectionsOptions<TSection extends string = string> {\n sections?: readonly TSection[]\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value)\n}\n\nfunction isKeyLike(value: unknown): value is KeyLike {\n return typeof value === \"string\" || isObject(value)\n}\n\nfunction cloneKeyLike(key: KeyLike): KeyLike {\n if (typeof key === \"string\") {\n return key\n }\n\n return { ...key }\n}\n\nfunction invalidBindingValue(section: string, command: string, index?: number): Error {\n const location = index === undefined ? `\"${section}.${command}\"` : `\"${section}.${command}\" at index ${index}`\n return new Error(\n `Invalid binding value for ${location}: expected false, a key, a binding object, or an array of keys/binding objects`,\n )\n}\n\nfunction resolveBindingItem<TTarget extends object, TEvent extends KeymapEvent>(\n section: string,\n command: string,\n item: BindingSectionItem<TTarget, TEvent>,\n index?: number,\n): Binding<TTarget, TEvent> {\n if (!isKeyLike(item)) {\n throw invalidBindingValue(section, command, index)\n }\n\n if (typeof item === \"string\" || !(\"key\" in item)) {\n return {\n key: cloneKeyLike(item),\n cmd: command,\n }\n }\n\n const key = item.key\n if (!isKeyLike(key)) {\n throw invalidBindingValue(section, command, index)\n }\n\n return {\n ...item,\n key: cloneKeyLike(key),\n cmd: command,\n }\n}\n\nfunction resolveBindingValue<TTarget extends object, TEvent extends KeymapEvent>(\n section: string,\n command: string,\n value: BindingValue<TTarget, TEvent>,\n): Binding<TTarget, TEvent>[] | undefined {\n if (value === false || value === \"none\") {\n return undefined\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined\n }\n\n const items = value as readonly BindingSectionItem<TTarget, TEvent>[]\n const bindings = new Array<Binding<TTarget, TEvent>>(items.length)\n for (let index = 0; index < items.length; index += 1) {\n bindings[index] = resolveBindingItem(section, command, items[index]!, index)\n }\n\n return bindings\n }\n\n return [resolveBindingItem(section, command, value as BindingSectionItem<TTarget, TEvent>)]\n}\n\nexport function resolveBindingSections<\n TTarget extends object = object,\n TEvent extends KeymapEvent = KeymapEvent,\n const TConfig extends BindingSectionsConfig<TTarget, TEvent> = BindingSectionsConfig<TTarget, TEvent>,\n const TSection extends string = string,\n>(\n config: TConfig,\n options: ResolveBindingSectionsOptions<TSection> & { sections: readonly TSection[] },\n): ResolvedBindingSections<TTarget, TEvent, TSection | LiteralStringKeys<TConfig>>\nexport function resolveBindingSections<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>(\n config: BindingSectionsConfig<TTarget, TEvent>,\n options?: ResolveBindingSectionsOptions,\n): ResolvedBindingSections<TTarget, TEvent>\nexport function resolveBindingSections<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>(\n config: BindingSectionsConfig<TTarget, TEvent>,\n options?: ResolveBindingSectionsOptions,\n): ResolvedBindingSections<TTarget, TEvent> {\n const sections: Record<string, Binding<TTarget, TEvent>[]> = {}\n const lookups = new Map<string, Map<string, Binding<TTarget, TEvent>[]>>()\n\n for (const section of options?.sections ?? []) {\n sections[section] = []\n lookups.set(section, new Map())\n }\n\n // Own-property loops avoid Object.entries allocations while still ignoring inherited config.\n for (const section in config) {\n if (!hasOwn.call(config, section)) {\n continue\n }\n\n const sectionConfig = config[section]\n if (!isObject(sectionConfig)) {\n throw new Error(`Invalid binding section \"${section}\": expected an object`)\n }\n\n const sectionLookup = new Map<string, Binding<TTarget, TEvent>[]>()\n\n for (const rawCommand in sectionConfig) {\n if (!hasOwn.call(sectionConfig, rawCommand)) {\n continue\n }\n\n const command = rawCommand.trim()\n const bindings = resolveBindingValue(section, command, sectionConfig[rawCommand]!)\n\n if (!bindings) {\n sectionLookup.delete(command)\n continue\n }\n\n sectionLookup.set(command, bindings)\n }\n\n // Manual flattening avoids Array.flat allocations on large generated configs.\n let sectionBindingCount = 0\n for (const bindings of sectionLookup.values()) {\n sectionBindingCount += bindings.length\n }\n\n const sectionBindings = new Array<Binding<TTarget, TEvent>>(sectionBindingCount)\n let bindingIndex = 0\n for (const bindings of sectionLookup.values()) {\n for (let index = 0; index < bindings.length; index += 1) {\n sectionBindings[bindingIndex] = bindings[index]!\n bindingIndex += 1\n }\n }\n\n sections[section] = sectionBindings\n lookups.set(section, sectionLookup)\n }\n\n return {\n sections,\n get(section, cmd) {\n return lookups.get(section)?.get(cmd.trim())\n },\n }\n}\n",
|
|
6
|
+
"import type { Binding, KeyLike, KeymapEvent } from \"../types.js\"\n\nexport type CommandBindingMap = Record<string, KeyLike>\n\nexport interface CommandBindingsOverrideWarning {\n code: \"command-binding-override\"\n command: string\n previousKey: KeyLike\n nextKey: KeyLike\n}\n\nexport interface CommandBindingsError {\n code: \"invalid-command-binding\"\n command: string\n value: unknown\n reason: Error\n}\n\nexport interface CommandBindingsOptions {\n onWarning?: (warning: CommandBindingsOverrideWarning) => void\n onError?: (error: CommandBindingsError) => void\n}\n\nfunction isCommandBindingKey(value: unknown): value is KeyLike {\n return typeof value === \"string\" || (!!value && typeof value === \"object\" && !Array.isArray(value))\n}\n\nexport function commandBindings<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>(\n bindings: Readonly<CommandBindingMap>,\n options?: CommandBindingsOptions,\n): Binding<TTarget, TEvent>[] {\n const normalized: Binding<TTarget, TEvent>[] = []\n const indexesByCommand = new Map<string, number>()\n\n for (const [command, key] of Object.entries(bindings)) {\n if (!isCommandBindingKey(key)) {\n const error = new Error(\n `Invalid command binding for \"${command}\": command bindings must map command strings to key strings or keystroke objects`,\n )\n\n options?.onError?.({\n code: \"invalid-command-binding\",\n command,\n value: key,\n reason: error,\n })\n continue\n }\n\n const normalizedCommand = command.trim()\n\n const nextBinding = {\n key: typeof key === \"string\" ? key : { ...key },\n cmd: normalizedCommand,\n } satisfies Binding<TTarget, TEvent>\n\n const existingIndex = indexesByCommand.get(normalizedCommand)\n if (existingIndex !== undefined) {\n const previousBinding = normalized[existingIndex]!\n options?.onWarning?.({\n code: \"command-binding-override\",\n command: normalizedCommand,\n previousKey: previousBinding.key,\n nextKey: nextBinding.key,\n })\n normalized[existingIndex] = nextBinding\n continue\n }\n\n indexesByCommand.set(normalizedCommand, normalized.length)\n normalized.push(nextBinding)\n }\n\n return normalized\n}\n",
|
|
7
|
+
"import type { KeySequencePart } from \"../types.js\"\n\nexport type KeyModifierName = \"ctrl\" | \"shift\" | \"meta\" | \"super\" | \"hyper\"\n\nexport interface KeySequenceFormatPart {\n stroke: KeySequencePart[\"stroke\"]\n display: string\n match?: KeySequencePart[\"match\"]\n tokenName?: string\n patternName?: string\n}\n\nexport type TokenDisplayResolver =\n | Readonly<Record<string, string>>\n | ((tokenName: string, part: KeySequenceFormatPart) => string | undefined)\n\nexport type PatternDisplayResolver =\n | Readonly<Record<string, string>>\n | ((patternName: string, part: KeySequenceFormatPart) => string | undefined)\n\nexport interface FormatKeySequenceOptions {\n tokenDisplay?: TokenDisplayResolver\n patternDisplay?: PatternDisplayResolver\n keyNameAliases?: Readonly<Record<string, string>>\n modifierAliases?: Partial<Record<KeyModifierName, string>>\n separator?: string\n}\n\nexport interface FormatCommandBindingsOptions extends FormatKeySequenceOptions {\n bindingSeparator?: string\n dedupe?: boolean\n}\n\nexport interface SequenceBindingLike {\n sequence: readonly KeySequenceFormatPart[]\n}\n\nfunction formatStroke(part: KeySequenceFormatPart, options: FormatKeySequenceOptions): string {\n if (part.tokenName) {\n const tokenDisplay = options.tokenDisplay\n if (!tokenDisplay) return part.display\n if (typeof tokenDisplay === \"function\") return tokenDisplay(part.tokenName, part) ?? part.display\n return tokenDisplay[part.tokenName] ?? part.display\n }\n\n if (part.patternName) {\n const patternDisplay = options.patternDisplay\n if (!patternDisplay) return part.display\n if (typeof patternDisplay === \"function\") return patternDisplay(part.patternName, part) ?? part.display\n return patternDisplay[part.patternName] ?? part.display\n }\n\n if (!options.keyNameAliases && !options.modifierAliases) return part.display\n\n // This is on the command-palette hot path; build directly to avoid per-stroke arrays.\n const stroke = part.stroke\n const modifierAliases = options.modifierAliases\n let formatted = \"\"\n let pieceCount = 0\n\n if (stroke.ctrl) {\n formatted = modifierAliases?.ctrl ?? \"ctrl\"\n pieceCount = 1\n }\n\n if (stroke.shift) {\n const alias = modifierAliases?.shift ?? \"shift\"\n formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`\n pieceCount += 1\n }\n\n if (stroke.meta) {\n const alias = modifierAliases?.meta ?? \"meta\"\n formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`\n pieceCount += 1\n }\n\n if (stroke.super) {\n const alias = modifierAliases?.super ?? \"super\"\n formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`\n pieceCount += 1\n }\n\n if (stroke.hyper) {\n const alias = modifierAliases?.hyper ?? \"hyper\"\n formatted = pieceCount === 0 ? alias : `${formatted}+${alias}`\n pieceCount += 1\n }\n\n const name = stroke.name === \"return\" ? \"enter\" : stroke.name\n const keyName = options.keyNameAliases?.[name] ?? name\n return pieceCount === 0 ? keyName : `${formatted}+${keyName}`\n}\n\nexport function formatKeySequence(\n parts: readonly KeySequenceFormatPart[] | undefined,\n options: FormatKeySequenceOptions = {},\n): string {\n if (!parts || parts.length === 0) return \"\"\n\n // Avoid map/join allocation here; binding-list formatting calls this repeatedly.\n const separator = options.separator ?? \" \"\n let formatted = formatStroke(parts[0]!, options)\n for (let index = 1; index < parts.length; index += 1) {\n formatted += separator + formatStroke(parts[index]!, options)\n }\n\n return formatted\n}\n\nexport function formatCommandBindings(\n bindings: readonly SequenceBindingLike[] | undefined,\n options: FormatCommandBindingsOptions = {},\n): string | undefined {\n if (!bindings?.length) return\n\n const bindingSeparator = options.bindingSeparator ?? \", \"\n const dedupe = options.dedupe !== false\n const seen = dedupe ? new Set<string>() : undefined\n let formatted = \"\"\n let itemCount = 0\n\n // One pass keeps dedupe, filtering, and joining allocation-light for large binding lists.\n for (const binding of bindings) {\n const item = formatKeySequence(binding.sequence, options)\n if (!item) continue\n\n if (seen) {\n if (seen.has(item)) continue\n seen.add(item)\n }\n\n formatted = itemCount === 0 ? item : `${formatted}${bindingSeparator}${item}`\n itemCount += 1\n }\n\n return formatted\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";;AAwBA,IAAM,SAAS,OAAO,UAAU;AAehC,SAAS,QAAQ,CAAC,OAAkD;AAAA,EAClE,OAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAAA;AAGrE,SAAS,SAAS,CAAC,OAAkC;AAAA,EACnD,OAAO,OAAO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AC9B,MAAM,OAAO,kBAAkB,QAAQ,UAAU,OAAO;AAAA,IACxD,IAAI,CAAC;AAAA,MAAM;AAAA,IAEX,IAAI,MAAM;AAAA,MACR,IAAI,KAAK,IAAI,IAAI;AAAA,QAAG;AAAA,MACpB,KAAK,IAAI,IAAI;AAAA,IACf;AAAA,IAEA,YAAY,cAAc,IAAI,OAAO,GAAG,YAAY,mBAAmB;AAAA,IACvE,aAAa;AAAA,EACf;AAAA,EAEA,OAAO;AAAA;",
|
|
10
|
+
"debugId": "7BE7E370039A4BC264756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActivationService } from "../../services/activation.js";
|
|
2
|
+
import type { CommandCatalogService } from "../../services/command-catalog.js";
|
|
3
|
+
import type { ConditionService } from "../../services/conditions.js";
|
|
4
|
+
import type { State } from "../../services/state.js";
|
|
5
|
+
import type { KeymapEvent, KeymapHost } from "../../types.js";
|
|
6
|
+
import type { GraphSnapshot, GraphSnapshotOptions } from "./graph-types.js";
|
|
7
|
+
export declare function createGraphSnapshot<TTarget extends object, TEvent extends KeymapEvent>(options: {
|
|
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
|
+
snapshotOptions?: GraphSnapshotOptions<TTarget>;
|
|
14
|
+
}): GraphSnapshot<TTarget, TEvent>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ActiveKey, Attributes, BindingCommand, BindingEvent, Command, KeymapEvent, KeyMatch, KeySequencePart, NormalizedKeyStroke, TargetMode } from "../../types.js";
|
|
2
|
+
export interface GraphSnapshotOptions<TTarget extends object = object> {
|
|
3
|
+
focused?: TTarget | null;
|
|
4
|
+
includeTargets?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type GraphInactiveReason = "focus" | "target-destroyed" | "layer-disabled" | "binding-disabled" | "command-disabled" | "command-inactive" | "command-unresolved" | "shadowed";
|
|
7
|
+
export interface GraphLayer<TTarget extends object = object> {
|
|
8
|
+
id: string;
|
|
9
|
+
order: number;
|
|
10
|
+
priority: number;
|
|
11
|
+
target?: TTarget;
|
|
12
|
+
targetMode?: TargetMode;
|
|
13
|
+
fields: Readonly<Record<string, unknown>>;
|
|
14
|
+
attrs?: Readonly<Attributes>;
|
|
15
|
+
active: boolean;
|
|
16
|
+
focusActive: boolean;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
inactiveReasons: readonly GraphInactiveReason[];
|
|
19
|
+
rootNodeId: string;
|
|
20
|
+
bindingIds: readonly string[];
|
|
21
|
+
commandIds: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export interface GraphCommand<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> {
|
|
24
|
+
id: string;
|
|
25
|
+
layerId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
command: Command<TTarget, TEvent>;
|
|
28
|
+
fields: Readonly<Record<string, unknown>>;
|
|
29
|
+
attrs?: Readonly<Attributes>;
|
|
30
|
+
target?: TTarget;
|
|
31
|
+
active: boolean;
|
|
32
|
+
reachable: boolean;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
inactiveReasons: readonly GraphInactiveReason[];
|
|
35
|
+
}
|
|
36
|
+
export interface GraphBinding<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> {
|
|
37
|
+
id: string;
|
|
38
|
+
layerId: string;
|
|
39
|
+
sourceLayerOrder: number;
|
|
40
|
+
bindingIndex: number;
|
|
41
|
+
nodeId?: string;
|
|
42
|
+
commandIds: readonly string[];
|
|
43
|
+
sequence: readonly KeySequencePart[];
|
|
44
|
+
command?: BindingCommand<TTarget, TEvent>;
|
|
45
|
+
commandAttrs?: Readonly<Attributes>;
|
|
46
|
+
attrs?: Readonly<Attributes>;
|
|
47
|
+
event: BindingEvent;
|
|
48
|
+
preventDefault: boolean;
|
|
49
|
+
fallthrough: boolean;
|
|
50
|
+
active: boolean;
|
|
51
|
+
reachable: boolean;
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
commandResolved: boolean;
|
|
54
|
+
shadowed: boolean;
|
|
55
|
+
inactiveReasons: readonly GraphInactiveReason[];
|
|
56
|
+
}
|
|
57
|
+
export interface GraphSequenceNode {
|
|
58
|
+
id: string;
|
|
59
|
+
layerId: string;
|
|
60
|
+
parentId: string | null;
|
|
61
|
+
childIds: readonly string[];
|
|
62
|
+
bindingIds: readonly string[];
|
|
63
|
+
reachableBindingIds: readonly string[];
|
|
64
|
+
depth: number;
|
|
65
|
+
sequence: readonly KeySequencePart[];
|
|
66
|
+
stroke: NormalizedKeyStroke | null;
|
|
67
|
+
match: KeyMatch | null;
|
|
68
|
+
display: string;
|
|
69
|
+
tokenName?: string;
|
|
70
|
+
active: boolean;
|
|
71
|
+
reachable: boolean;
|
|
72
|
+
pending: boolean;
|
|
73
|
+
pendingPath: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface GraphSnapshot<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> {
|
|
76
|
+
focused?: TTarget | null;
|
|
77
|
+
pendingSequence: readonly KeySequencePart[];
|
|
78
|
+
activeKeys: readonly ActiveKey<TTarget, TEvent>[];
|
|
79
|
+
layers: readonly GraphLayer<TTarget>[];
|
|
80
|
+
commands: readonly GraphCommand<TTarget, TEvent>[];
|
|
81
|
+
bindings: readonly GraphBinding<TTarget, TEvent>[];
|
|
82
|
+
sequenceNodes: readonly GraphSequenceNode[];
|
|
83
|
+
}
|
package/src/html.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Keymap } from "
|
|
2
|
-
import type { EventMatchResolver, KeymapEvent, KeymapHost } from "
|
|
3
|
-
export * from "./index.js";
|
|
1
|
+
import { Keymap } from "@opentui/keymap";
|
|
2
|
+
import type { EventMatchResolver, KeymapEvent, KeymapHost } from "@opentui/keymap";
|
|
4
3
|
export interface HtmlKeymapEvent extends KeymapEvent {
|
|
5
4
|
readonly originalEvent?: KeyboardEvent;
|
|
6
5
|
}
|
|
@@ -19,3 +18,4 @@ export declare function createHtmlKeymapHost(root: HTMLElement): KeymapHost<HTML
|
|
|
19
18
|
export declare const htmlEventMatchResolver: EventMatchResolver<HtmlKeymapEvent>;
|
|
20
19
|
export declare function createHtmlKeymap(root: HTMLElement): Keymap<HTMLElement, HtmlKeymapEvent>;
|
|
21
20
|
export declare function createDefaultHtmlKeymap(root: HTMLElement): Keymap<HTMLElement, HtmlKeymapEvent>;
|
|
21
|
+
export {};
|