@opentui/keymap 0.5.10 → 0.5.12
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/chunks/{index-frk6sdcd.js → index-7g381cth.js} +8 -8
- package/chunks/{index-frk6sdcd.js.map → index-7g381cth.js.map} +2 -2
- package/package.json +5 -5
- package/src/addons/index.js +20 -22
- package/src/addons/index.js.map +2 -2
- package/src/addons/opentui/index.js +5 -7
- package/src/addons/opentui/index.js.map +2 -2
- package/src/extras/graph.js +46 -47
- package/src/extras/graph.js.map +2 -2
- package/src/extras/index.js +11 -13
- package/src/extras/index.js.map +2 -2
- package/src/html.js +6 -8
- package/src/html.js.map +2 -2
- package/src/index.js +125 -126
- package/src/index.js.map +2 -2
- package/src/opentui.js +3 -5
- package/src/opentui.js.map +2 -2
- package/src/react/index.js +6 -8
- package/src/react/index.js.map +2 -2
- package/src/runtime-modules.js +1 -5
- package/src/runtime-modules.js.map +2 -2
- package/src/solid/index.js +7 -9
- package/src/solid/index.js.map +2 -2
- package/src/testing/index.js +8 -10
- package/src/testing/index.js.map +2 -2
- package/chunks/index-p35cyhc4.js +0 -7
- package/chunks/index-p35cyhc4.js.map +0 -9
package/src/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
activeOptionsForCaptures,
|
|
5
|
-
advanceSequenceCapture,
|
|
6
|
-
buildSequenceTree,
|
|
7
|
-
captureHasContinuations,
|
|
8
|
-
captureIsExact,
|
|
9
|
-
capturePriority,
|
|
10
|
-
cloneKeySequence,
|
|
3
|
+
normalizeBindingTokenName,
|
|
11
4
|
cloneKeyStroke,
|
|
12
|
-
collectRootSequenceCaptures,
|
|
13
5
|
createKeySequencePart,
|
|
6
|
+
cloneKeySequence,
|
|
7
|
+
resolveKeyMatch,
|
|
14
8
|
createTextKeyMatch,
|
|
15
|
-
|
|
9
|
+
stringifyKeyStroke2,
|
|
10
|
+
stringifyKeySequence2,
|
|
16
11
|
getFocusedTargetIfAvailable,
|
|
12
|
+
getActiveLayersForFocused,
|
|
17
13
|
isLayerActiveForFocused,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
captureHasContinuations,
|
|
15
|
+
captureIsExact,
|
|
16
|
+
buildSequenceTree,
|
|
17
|
+
activeOptionsForCaptures,
|
|
18
|
+
capturePriority,
|
|
19
|
+
advanceSequenceCapture,
|
|
20
|
+
collectRootSequenceCaptures,
|
|
21
|
+
KEYMAP_EXTENSION_CONTEXT2
|
|
22
|
+
} from "../chunks/index-7g381cth.js";
|
|
24
23
|
|
|
25
24
|
// src/lib/runtime-utils.ts
|
|
26
25
|
function createRuntimeEmitter(onError) {
|
|
@@ -371,7 +370,7 @@ function collectSequencePartsFromPending(pending) {
|
|
|
371
370
|
}
|
|
372
371
|
}
|
|
373
372
|
if (display === undefined || hasDisplayConflict) {
|
|
374
|
-
display =
|
|
373
|
+
display = stringifyKeyStroke2(firstPart.stroke);
|
|
375
374
|
}
|
|
376
375
|
if (hasTokenConflict) {
|
|
377
376
|
tokenName = undefined;
|
|
@@ -477,10 +476,10 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
477
476
|
setPendingSequence({ captures: nextCaptures });
|
|
478
477
|
return true;
|
|
479
478
|
};
|
|
480
|
-
const getActiveKeys = (
|
|
481
|
-
const includeBindings =
|
|
482
|
-
const includeMetadata =
|
|
483
|
-
const cache = getActiveKeysCache(activeKeysCaches,
|
|
479
|
+
const getActiveKeys = (options) => {
|
|
480
|
+
const includeBindings = options?.includeBindings === true;
|
|
481
|
+
const includeMetadata = options?.includeMetadata === true;
|
|
482
|
+
const cache = getActiveKeysCache(activeKeysCaches, options);
|
|
484
483
|
if (cache.notifyVersion === state.derivedVersion) {
|
|
485
484
|
return cache.value;
|
|
486
485
|
}
|
|
@@ -513,16 +512,16 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
513
512
|
}
|
|
514
513
|
return activeKeys;
|
|
515
514
|
};
|
|
516
|
-
const getActiveKeysForCaptures = (captures,
|
|
517
|
-
const includeBindings =
|
|
518
|
-
const includeMetadata =
|
|
515
|
+
const getActiveKeysForCaptures = (captures, options) => {
|
|
516
|
+
const includeBindings = options?.includeBindings === true;
|
|
517
|
+
const includeMetadata = options?.includeMetadata === true;
|
|
519
518
|
const focused = getFocusedTarget();
|
|
520
519
|
const activeView = catalog.getActiveCommandView(focused);
|
|
521
520
|
return collectActiveKeysFromPending(captures, includeBindings, includeMetadata, focused, activeView);
|
|
522
521
|
};
|
|
523
|
-
const getActiveKeysForFocused = (focused,
|
|
524
|
-
const includeBindings =
|
|
525
|
-
const includeMetadata =
|
|
522
|
+
const getActiveKeysForFocused = (focused, options) => {
|
|
523
|
+
const includeBindings = options?.includeBindings === true;
|
|
524
|
+
const includeMetadata = options?.includeMetadata === true;
|
|
526
525
|
const currentFocused = getFocusedTargetIfAvailable2();
|
|
527
526
|
const pending = focused === currentFocused ? ensureValidPendingSequence() : undefined;
|
|
528
527
|
const activeView = catalog.getActiveCommandView(focused);
|
|
@@ -585,7 +584,7 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
585
584
|
}
|
|
586
585
|
if (display === undefined || hasDisplayConflict) {
|
|
587
586
|
const stroke = bindings[0]?.sequence[partIndex]?.stroke;
|
|
588
|
-
display = stroke ?
|
|
587
|
+
display = stroke ? stringifyKeyStroke2(stroke) : "";
|
|
589
588
|
}
|
|
590
589
|
if (hasTokenConflict) {
|
|
591
590
|
tokenName = undefined;
|
|
@@ -645,19 +644,19 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
645
644
|
const selectActiveKeyNode = (node, includeBindings, focused, activeView) => {
|
|
646
645
|
const continues = node.children.size > 0 || node.patternChildren.length > 0;
|
|
647
646
|
if (!continues) {
|
|
648
|
-
const
|
|
649
|
-
if (!
|
|
647
|
+
const selected = selectActiveBindings(nodeExactBindingsNeedPrefilter(node) ? collectMatchingBindings(node.bindings, focused, activeView) : node.bindings, focused, activeView);
|
|
648
|
+
if (!selected) {
|
|
650
649
|
return;
|
|
651
650
|
}
|
|
652
|
-
const
|
|
651
|
+
const presentation = getPartPresentation(selected.bindings, node.depth - 1);
|
|
653
652
|
return {
|
|
654
|
-
display:
|
|
655
|
-
tokenName:
|
|
653
|
+
display: presentation.display,
|
|
654
|
+
tokenName: presentation.tokenName,
|
|
656
655
|
continues: false,
|
|
657
|
-
firstBinding:
|
|
658
|
-
commandBinding:
|
|
659
|
-
bindings: includeBindings ? [...
|
|
660
|
-
stop:
|
|
656
|
+
firstBinding: selected.bindings[0],
|
|
657
|
+
commandBinding: selected.commandBinding,
|
|
658
|
+
bindings: includeBindings ? [...selected.bindings] : undefined,
|
|
659
|
+
stop: selected.stop
|
|
661
660
|
};
|
|
662
661
|
}
|
|
663
662
|
const reachableBindings = collectMatchingBindings(node.reachableBindings, focused, activeView);
|
|
@@ -693,14 +692,14 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
693
692
|
collectActiveKeyOptions(activeOptionsForCaptures(captures, state.patterns), activeKeys, stopped, includeBindings, focused, activeView);
|
|
694
693
|
return materializeActiveKeys(activeKeys, includeBindings, includeMetadata, focused, activeView);
|
|
695
694
|
};
|
|
696
|
-
const collectActiveKeyOptions = (
|
|
695
|
+
const collectActiveKeyOptions = (options, activeKeys, stopped, includeBindings, focused, activeView) => {
|
|
697
696
|
const seen = new Set;
|
|
698
|
-
for (const option of
|
|
697
|
+
for (const option of options) {
|
|
699
698
|
if (seen.has(option.part.match)) {
|
|
700
699
|
continue;
|
|
701
700
|
}
|
|
702
701
|
seen.add(option.part.match);
|
|
703
|
-
collectActiveKeyOption(option,
|
|
702
|
+
collectActiveKeyOption(option, options, activeKeys, stopped, includeBindings, focused, activeView);
|
|
704
703
|
}
|
|
705
704
|
};
|
|
706
705
|
const collectActiveKeyOption = (option, siblingOptions, activeKeys, stopped, includeBindings, focused, activeView) => {
|
|
@@ -724,8 +723,8 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
724
723
|
};
|
|
725
724
|
const materializeActiveKeys = (activeKeys, includeBindings, includeMetadata, focused, activeView) => {
|
|
726
725
|
const materialized = [];
|
|
727
|
-
for (const
|
|
728
|
-
const activeKey = materializeActiveKey(
|
|
726
|
+
for (const state of activeKeys.values()) {
|
|
727
|
+
const activeKey = materializeActiveKey(state, includeBindings, includeMetadata, focused, activeView);
|
|
729
728
|
if (activeKey) {
|
|
730
729
|
materialized.push(activeKey);
|
|
731
730
|
}
|
|
@@ -751,12 +750,12 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
751
750
|
stop: continues || selected?.stop === true
|
|
752
751
|
};
|
|
753
752
|
};
|
|
754
|
-
const getOptionPresentation = (
|
|
753
|
+
const getOptionPresentation = (options) => {
|
|
755
754
|
let display;
|
|
756
755
|
let tokenName;
|
|
757
756
|
let hasDisplayConflict = false;
|
|
758
757
|
let hasTokenConflict = false;
|
|
759
|
-
for (const option of
|
|
758
|
+
for (const option of options) {
|
|
760
759
|
const part = option.part;
|
|
761
760
|
if (display === undefined) {
|
|
762
761
|
display = part.display;
|
|
@@ -770,9 +769,9 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
770
769
|
hasTokenConflict = true;
|
|
771
770
|
}
|
|
772
771
|
}
|
|
773
|
-
const firstPart =
|
|
772
|
+
const firstPart = options[0]?.part;
|
|
774
773
|
if (display === undefined || hasDisplayConflict) {
|
|
775
|
-
display = firstPart ?
|
|
774
|
+
display = firstPart ? stringifyKeyStroke2(firstPart.stroke) : "";
|
|
776
775
|
}
|
|
777
776
|
if (hasTokenConflict) {
|
|
778
777
|
tokenName = undefined;
|
|
@@ -811,48 +810,48 @@ function createActivationService(state, host, hooks, notify, conditions, catalog
|
|
|
811
810
|
bindings: includeBindings && selection.bindings ? [...selection.bindings] : undefined
|
|
812
811
|
};
|
|
813
812
|
};
|
|
814
|
-
const updateActiveKeyState = (
|
|
815
|
-
if (!
|
|
816
|
-
|
|
813
|
+
const updateActiveKeyState = (state, selection, includeBindings) => {
|
|
814
|
+
if (!state.firstBinding && selection.firstBinding) {
|
|
815
|
+
state.firstBinding = selection.firstBinding;
|
|
817
816
|
}
|
|
818
|
-
if (!
|
|
819
|
-
|
|
817
|
+
if (!state.commandBinding && selection.commandBinding) {
|
|
818
|
+
state.commandBinding = selection.commandBinding;
|
|
820
819
|
}
|
|
821
820
|
if (selection.continues) {
|
|
822
|
-
|
|
821
|
+
state.continues = true;
|
|
823
822
|
}
|
|
824
823
|
if (!includeBindings || !selection.bindings || selection.bindings.length === 0) {
|
|
825
824
|
return;
|
|
826
825
|
}
|
|
827
|
-
if (!
|
|
828
|
-
|
|
826
|
+
if (!state.bindings) {
|
|
827
|
+
state.bindings = [...selection.bindings];
|
|
829
828
|
return;
|
|
830
829
|
}
|
|
831
|
-
|
|
830
|
+
state.bindings.push(...selection.bindings);
|
|
832
831
|
};
|
|
833
|
-
const materializeActiveKey = (
|
|
834
|
-
if (!
|
|
832
|
+
const materializeActiveKey = (state, includeBindings, includeMetadata, focused, activeView) => {
|
|
833
|
+
if (!state.commandBinding && !state.continues) {
|
|
835
834
|
return;
|
|
836
835
|
}
|
|
837
836
|
const activeKey = {
|
|
838
|
-
stroke: cloneKeyStroke(
|
|
839
|
-
display:
|
|
840
|
-
continues:
|
|
837
|
+
stroke: cloneKeyStroke(state.stroke),
|
|
838
|
+
display: state.display,
|
|
839
|
+
continues: state.continues
|
|
841
840
|
};
|
|
842
|
-
if (
|
|
843
|
-
activeKey.tokenName =
|
|
841
|
+
if (state.tokenName) {
|
|
842
|
+
activeKey.tokenName = state.tokenName;
|
|
844
843
|
}
|
|
845
|
-
if (
|
|
846
|
-
activeKey.command =
|
|
844
|
+
if (state.commandBinding) {
|
|
845
|
+
activeKey.command = state.commandBinding.command;
|
|
847
846
|
}
|
|
848
|
-
if (includeBindings &&
|
|
849
|
-
activeKey.bindings =
|
|
847
|
+
if (includeBindings && state.bindings && state.bindings.length > 0) {
|
|
848
|
+
activeKey.bindings = state.bindings.length === 1 ? [toActiveBinding(state.bindings[0], focused, activeView)] : collectActiveBindings(state.bindings, focused, activeView);
|
|
850
849
|
}
|
|
851
850
|
if (includeMetadata) {
|
|
852
|
-
if (
|
|
853
|
-
activeKey.bindingAttrs =
|
|
851
|
+
if (state.firstBinding?.attrs) {
|
|
852
|
+
activeKey.bindingAttrs = state.firstBinding.attrs;
|
|
854
853
|
}
|
|
855
|
-
const commandAttrs =
|
|
854
|
+
const commandAttrs = state.commandBinding ? catalog.getBindingCommandAttrs(state.commandBinding, focused, activeView) : undefined;
|
|
856
855
|
if (commandAttrs) {
|
|
857
856
|
activeKey.commandAttrs = commandAttrs;
|
|
858
857
|
}
|
|
@@ -1136,11 +1135,11 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1136
1135
|
const getResolvedCommandChain = (command, focused, execution) => {
|
|
1137
1136
|
const view = getActiveCommandView2(focused);
|
|
1138
1137
|
if (execution) {
|
|
1139
|
-
const
|
|
1138
|
+
const resolved = [];
|
|
1140
1139
|
const chain = view.chainsByName.get(command);
|
|
1141
1140
|
if (chain) {
|
|
1142
1141
|
for (const entry of chain) {
|
|
1143
|
-
|
|
1142
|
+
resolved.push({
|
|
1144
1143
|
target: entry.layer.target,
|
|
1145
1144
|
command: entry.commandState.command,
|
|
1146
1145
|
attrs: entry.commandState.attrs,
|
|
@@ -1148,11 +1147,11 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1148
1147
|
});
|
|
1149
1148
|
}
|
|
1150
1149
|
}
|
|
1151
|
-
const
|
|
1152
|
-
if (
|
|
1153
|
-
|
|
1150
|
+
const fallback = resolveCommandWithResolversForMode(command, focused, { mode: "active", execution });
|
|
1151
|
+
if (fallback.resolved) {
|
|
1152
|
+
resolved.push(fallback.resolved);
|
|
1154
1153
|
}
|
|
1155
|
-
return { entries:
|
|
1154
|
+
return { entries: resolved.length > 0 ? resolved : undefined, hadError: fallback.hadError };
|
|
1156
1155
|
}
|
|
1157
1156
|
const resolved = [];
|
|
1158
1157
|
for (const entry of view.chainsByName.get(command) ?? []) {
|
|
@@ -1246,23 +1245,23 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1246
1245
|
const activeCommandViewCanCache = () => {
|
|
1247
1246
|
return state.activeCommandViewCacheBlockers === 0;
|
|
1248
1247
|
};
|
|
1249
|
-
const isBindingVisible = (binding, focused,
|
|
1248
|
+
const isBindingVisible = (binding, focused, activeView) => {
|
|
1250
1249
|
if (binding.command === undefined || binding.run) {
|
|
1251
1250
|
return true;
|
|
1252
1251
|
}
|
|
1253
1252
|
if (typeof binding.command !== "string") {
|
|
1254
1253
|
return false;
|
|
1255
1254
|
}
|
|
1256
|
-
if (
|
|
1255
|
+
if (activeView.reachableByName.has(binding.command)) {
|
|
1257
1256
|
return true;
|
|
1258
1257
|
}
|
|
1259
1258
|
return getFallbackResolvedCommand(binding.command, focused, "active") !== undefined;
|
|
1260
1259
|
};
|
|
1261
|
-
const getBindingCommandAttrs = (binding, focused,
|
|
1260
|
+
const getBindingCommandAttrs = (binding, focused, activeView) => {
|
|
1262
1261
|
if (typeof binding.command !== "string") {
|
|
1263
1262
|
return;
|
|
1264
1263
|
}
|
|
1265
|
-
const active =
|
|
1264
|
+
const active = activeView.reachableByName.get(binding.command);
|
|
1266
1265
|
if (active) {
|
|
1267
1266
|
return active.commandState.attrs;
|
|
1268
1267
|
}
|
|
@@ -1270,7 +1269,7 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1270
1269
|
return fallback?.attrs;
|
|
1271
1270
|
};
|
|
1272
1271
|
const getCommandResolutionStatus = (command, layerCommands) => {
|
|
1273
|
-
if (layerCommands?.some((
|
|
1272
|
+
if (layerCommands?.some((state) => state.command.name === command) || getCommandView().chainsByName.has(command)) {
|
|
1274
1273
|
return "resolved";
|
|
1275
1274
|
}
|
|
1276
1275
|
const lookup = resolveCommandWithResolversForMode(command, getFocusedTargetIfAvailable(host));
|
|
@@ -1297,8 +1296,8 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1297
1296
|
});
|
|
1298
1297
|
};
|
|
1299
1298
|
const getTopResolvedCommand = (command, focused) => {
|
|
1300
|
-
const
|
|
1301
|
-
const active =
|
|
1299
|
+
const activeView = getActiveCommandView2(focused);
|
|
1300
|
+
const active = activeView.reachableByName.get(command);
|
|
1302
1301
|
if (active) {
|
|
1303
1302
|
return {
|
|
1304
1303
|
target: active.layer.target,
|
|
@@ -1419,16 +1418,16 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1419
1418
|
}
|
|
1420
1419
|
return;
|
|
1421
1420
|
}
|
|
1422
|
-
const
|
|
1423
|
-
if (!
|
|
1421
|
+
const activeView = context.activeView;
|
|
1422
|
+
if (!activeView) {
|
|
1424
1423
|
return;
|
|
1425
1424
|
}
|
|
1426
|
-
for (const layer of
|
|
1425
|
+
for (const layer of activeView.layers) {
|
|
1427
1426
|
if (layer.bindings.length === 0 || !conditions.matchesConditions(layer)) {
|
|
1428
1427
|
continue;
|
|
1429
1428
|
}
|
|
1430
1429
|
for (const binding of layer.bindings) {
|
|
1431
|
-
if (conditions.matchesConditions(binding) && isBindingVisible(binding, context.focused,
|
|
1430
|
+
if (conditions.matchesConditions(binding) && isBindingVisible(binding, context.focused, activeView)) {
|
|
1432
1431
|
visit(binding);
|
|
1433
1432
|
}
|
|
1434
1433
|
}
|
|
@@ -1478,15 +1477,15 @@ function createCommandCatalogService(state, host, notify, conditions, options) {
|
|
|
1478
1477
|
if (context.visibility === "registered") {
|
|
1479
1478
|
return getCommandView().chainsByName.get(binding.command)?.[0]?.commandState.attrs;
|
|
1480
1479
|
}
|
|
1481
|
-
const
|
|
1482
|
-
if (!
|
|
1480
|
+
const activeView = context.activeView;
|
|
1481
|
+
if (!activeView) {
|
|
1483
1482
|
return;
|
|
1484
1483
|
}
|
|
1485
|
-
return getBindingCommandAttrs(binding, context.focused,
|
|
1484
|
+
return getBindingCommandAttrs(binding, context.focused, activeView);
|
|
1486
1485
|
};
|
|
1487
|
-
const resolveCommandWithResolversForMode = (command, focused,
|
|
1488
|
-
const mode =
|
|
1489
|
-
const execution =
|
|
1486
|
+
const resolveCommandWithResolversForMode = (command, focused, options) => {
|
|
1487
|
+
const mode = options?.mode ?? "active";
|
|
1488
|
+
const execution = options?.execution ?? { input: command };
|
|
1490
1489
|
const lookup = resolveCommandWithResolvers(command, state.commandResolvers.values(), () => createCommandResolverContext(focused, mode, execution), (error) => {
|
|
1491
1490
|
notify.emitError("command-resolver-error", error, `[Keymap] Error in command resolver for "${command}":`);
|
|
1492
1491
|
});
|
|
@@ -2057,7 +2056,7 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2057
2056
|
tokens: state.tokens,
|
|
2058
2057
|
patterns: state.patterns,
|
|
2059
2058
|
layer: EMPTY_COMPILE_FIELDS,
|
|
2060
|
-
parseObjectKey: (value,
|
|
2059
|
+
parseObjectKey: (value, options) => parseObjectKeyPart(value, options)
|
|
2061
2060
|
});
|
|
2062
2061
|
};
|
|
2063
2062
|
const parseKeySequence = (key) => {
|
|
@@ -2068,7 +2067,7 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2068
2067
|
tokens: state.tokens,
|
|
2069
2068
|
patterns: state.patterns,
|
|
2070
2069
|
layer: EMPTY_COMPILE_FIELDS,
|
|
2071
|
-
parseObjectKey: (value,
|
|
2070
|
+
parseObjectKey: (value, options) => parseObjectKeyPart(value, options)
|
|
2072
2071
|
});
|
|
2073
2072
|
for (const tokenName of parsed.unknownTokens) {
|
|
2074
2073
|
options.warnUnknownToken(tokenName, key);
|
|
@@ -2078,8 +2077,8 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2078
2077
|
}
|
|
2079
2078
|
return parsed.parts;
|
|
2080
2079
|
};
|
|
2081
|
-
const formatKey = (key,
|
|
2082
|
-
return
|
|
2080
|
+
const formatKey = (key, options) => {
|
|
2081
|
+
return stringifyKeySequence2(parseKeySequence(key), options);
|
|
2083
2082
|
};
|
|
2084
2083
|
const compileBindings = (bindings, tokens, sourceTarget, sourceLayerOrder, compileFields) => {
|
|
2085
2084
|
const bindingStates = [];
|
|
@@ -2108,7 +2107,7 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2108
2107
|
tokens,
|
|
2109
2108
|
patterns: state.patterns,
|
|
2110
2109
|
layer: compileFields,
|
|
2111
|
-
parseObjectKey: (value,
|
|
2110
|
+
parseObjectKey: (value, options) => parseObjectKeyPart(value, options)
|
|
2112
2111
|
}) : {
|
|
2113
2112
|
parts: [parseObjectKeyPart(expandedKey)],
|
|
2114
2113
|
usedTokens: [],
|
|
@@ -2209,8 +2208,8 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2209
2208
|
hasTokenBindings
|
|
2210
2209
|
};
|
|
2211
2210
|
};
|
|
2212
|
-
const parseObjectKeyPart = (key,
|
|
2213
|
-
return createKeySequencePart(key,
|
|
2211
|
+
const parseObjectKeyPart = (key, options) => {
|
|
2212
|
+
return createKeySequencePart(key, options);
|
|
2214
2213
|
};
|
|
2215
2214
|
const normalizeBindingEvent = (event) => {
|
|
2216
2215
|
if (event === undefined || event === "press") {
|
|
@@ -2242,7 +2241,7 @@ function createCompilerService(state, notify, conditions, options) {
|
|
|
2242
2241
|
tokens,
|
|
2243
2242
|
patterns: state.patterns,
|
|
2244
2243
|
layer,
|
|
2245
|
-
parseObjectKey: (value,
|
|
2244
|
+
parseObjectKey: (value, options) => parseObjectKeyPart(value, options)
|
|
2246
2245
|
});
|
|
2247
2246
|
},
|
|
2248
2247
|
add: (nextBinding) => {
|
|
@@ -2633,8 +2632,8 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2633
2632
|
cancelPendingDisambiguation();
|
|
2634
2633
|
}
|
|
2635
2634
|
function handleRawSequence(sequence) {
|
|
2636
|
-
const
|
|
2637
|
-
if (
|
|
2635
|
+
const hooks = state.rawHooks.entries();
|
|
2636
|
+
if (hooks.length === 0) {
|
|
2638
2637
|
return false;
|
|
2639
2638
|
}
|
|
2640
2639
|
let stopped = false;
|
|
@@ -2644,7 +2643,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2644
2643
|
stopped = true;
|
|
2645
2644
|
}
|
|
2646
2645
|
};
|
|
2647
|
-
for (const hook of
|
|
2646
|
+
for (const hook of hooks) {
|
|
2648
2647
|
try {
|
|
2649
2648
|
hook.listener(context);
|
|
2650
2649
|
} catch (error) {
|
|
@@ -2714,10 +2713,10 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2714
2713
|
});
|
|
2715
2714
|
}
|
|
2716
2715
|
function getKeyAfterHooks(release) {
|
|
2717
|
-
const
|
|
2718
|
-
for (const hook of
|
|
2716
|
+
const hooks = state.keyAfterHooks.entries();
|
|
2717
|
+
for (const hook of hooks) {
|
|
2719
2718
|
if (hook.release === release) {
|
|
2720
|
-
return
|
|
2719
|
+
return hooks;
|
|
2721
2720
|
}
|
|
2722
2721
|
}
|
|
2723
2722
|
return;
|
|
@@ -2751,7 +2750,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2751
2750
|
}
|
|
2752
2751
|
return current;
|
|
2753
2752
|
}
|
|
2754
|
-
function emitKeyAfter(
|
|
2753
|
+
function emitKeyAfter(hooks, event, release, focused, outcome) {
|
|
2755
2754
|
const context = {
|
|
2756
2755
|
event,
|
|
2757
2756
|
eventType: release ? "release" : "press",
|
|
@@ -2777,7 +2776,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2777
2776
|
}
|
|
2778
2777
|
}
|
|
2779
2778
|
};
|
|
2780
|
-
for (const hook of
|
|
2779
|
+
for (const hook of hooks) {
|
|
2781
2780
|
if (hook.release !== release) {
|
|
2782
2781
|
continue;
|
|
2783
2782
|
}
|
|
@@ -2815,7 +2814,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2815
2814
|
}
|
|
2816
2815
|
const afterHooks = getKeyAfterHooks(release);
|
|
2817
2816
|
const afterFocused = afterHooks ? activation.getFocusedTarget() : null;
|
|
2818
|
-
const
|
|
2817
|
+
const hooks = state.keyHooks.entries();
|
|
2819
2818
|
const context = {
|
|
2820
2819
|
event,
|
|
2821
2820
|
setData: (name, value) => {
|
|
@@ -2835,7 +2834,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2835
2834
|
}
|
|
2836
2835
|
}
|
|
2837
2836
|
};
|
|
2838
|
-
for (const hook of
|
|
2837
|
+
for (const hook of hooks) {
|
|
2839
2838
|
if (hook.release !== release) {
|
|
2840
2839
|
continue;
|
|
2841
2840
|
}
|
|
@@ -2856,9 +2855,9 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2856
2855
|
}
|
|
2857
2856
|
}
|
|
2858
2857
|
if (release) {
|
|
2859
|
-
const
|
|
2858
|
+
const outcome = dispatchReleaseLayers(event);
|
|
2860
2859
|
if (afterHooks) {
|
|
2861
|
-
emitKeyAfter(afterHooks, event, release, afterFocused,
|
|
2860
|
+
emitKeyAfter(afterHooks, event, release, afterFocused, outcome);
|
|
2862
2861
|
}
|
|
2863
2862
|
return;
|
|
2864
2863
|
}
|
|
@@ -2967,8 +2966,8 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
2967
2966
|
if (hasHandledExact) {
|
|
2968
2967
|
continue;
|
|
2969
2968
|
}
|
|
2970
|
-
const
|
|
2971
|
-
const resolvedOutcome = tryResolvePendingAmbiguity(advancedCaptures, index, continuationCapturesForPrefix,
|
|
2969
|
+
const exactCaptures = collectExactCapturesForPrefix(advancedCaptures, capture);
|
|
2970
|
+
const resolvedOutcome = tryResolvePendingAmbiguity(advancedCaptures, index, continuationCapturesForPrefix, exactCaptures, event, focused, hasHandledExact);
|
|
2972
2971
|
if (resolvedOutcome) {
|
|
2973
2972
|
return resolvedOutcome;
|
|
2974
2973
|
}
|
|
@@ -3016,9 +3015,9 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
3016
3015
|
}
|
|
3017
3016
|
const layerContinuationCaptures = captures.filter((capture) => captureHasContinuations(capture, state.patterns, false));
|
|
3018
3017
|
if (layerContinuationCaptures.length > 0) {
|
|
3019
|
-
const
|
|
3018
|
+
const exactCaptures = captures.filter((capture) => captureIsExact(capture, state.patterns));
|
|
3020
3019
|
const continuationCaptures = collectPendingCapturesFromRoot(activeLayers, index, matchKeys, event, focused);
|
|
3021
|
-
const resolvedOutcome = tryResolveRootAmbiguity(activeLayers, index, matchKeys, continuationCaptures,
|
|
3020
|
+
const resolvedOutcome = tryResolveRootAmbiguity(activeLayers, index, matchKeys, continuationCaptures, exactCaptures, event, focused);
|
|
3022
3021
|
if (resolvedOutcome) {
|
|
3023
3022
|
return resolvedOutcome;
|
|
3024
3023
|
}
|
|
@@ -3294,7 +3293,7 @@ function createDispatchService(state, notify, runtime, activation, conditions, e
|
|
|
3294
3293
|
return pendingDisambiguation === pending;
|
|
3295
3294
|
}
|
|
3296
3295
|
function warnUnresolvedAmbiguity(sequence) {
|
|
3297
|
-
const display =
|
|
3296
|
+
const display = stringifyKeySequence2(sequence, { preferDisplay: true });
|
|
3298
3297
|
notify.warnOnce(`unresolved-disambiguation:${display}`, "unresolved-disambiguation", { sequence: display }, `[Keymap] Ambiguous exact/prefix sequence "${display}" fell back to prefix handling because no disambiguation resolver resolved it`);
|
|
3299
3298
|
}
|
|
3300
3299
|
function collectPendingCapturesFromRoot(activeLayers, startIndex, matchKeys, event, focused) {
|
|
@@ -3564,10 +3563,10 @@ function registerToken(state, notify, compiler, layers, token) {
|
|
|
3564
3563
|
if (current !== registeredToken) {
|
|
3565
3564
|
return;
|
|
3566
3565
|
}
|
|
3567
|
-
const
|
|
3568
|
-
|
|
3566
|
+
const nextTokens = new Map(state.tokens);
|
|
3567
|
+
nextTokens.delete(normalizedToken);
|
|
3569
3568
|
try {
|
|
3570
|
-
layers.applyTokenState(
|
|
3569
|
+
layers.applyTokenState(nextTokens);
|
|
3571
3570
|
} catch (error) {
|
|
3572
3571
|
notify.emitError("token-unregister-error", error, getErrorMessage(error, `Failed to unregister keymap token "${normalizedToken}"`));
|
|
3573
3572
|
}
|
|
@@ -3807,7 +3806,7 @@ function createLayerService(state, notify, conditions, activation, options) {
|
|
|
3807
3806
|
for (const transformer of transformers) {
|
|
3808
3807
|
const next = transformer(current, {
|
|
3809
3808
|
layer,
|
|
3810
|
-
validateBindings: (
|
|
3809
|
+
validateBindings: (bindings) => validateBindings(bindings)
|
|
3811
3810
|
});
|
|
3812
3811
|
if (!next) {
|
|
3813
3812
|
continue;
|
|
@@ -4264,7 +4263,7 @@ class Keymap {
|
|
|
4264
4263
|
}));
|
|
4265
4264
|
}
|
|
4266
4265
|
}
|
|
4267
|
-
[
|
|
4266
|
+
[KEYMAP_EXTENSION_CONTEXT2]() {
|
|
4268
4267
|
return {
|
|
4269
4268
|
state: this.#state,
|
|
4270
4269
|
host: this.#host,
|
|
@@ -4497,11 +4496,11 @@ class Keymap {
|
|
|
4497
4496
|
}
|
|
4498
4497
|
}
|
|
4499
4498
|
export {
|
|
4500
|
-
|
|
4501
|
-
stringifyKeySequence,
|
|
4499
|
+
KEYMAP_EXTENSION_CONTEXT2 as KEYMAP_EXTENSION_CONTEXT,
|
|
4502
4500
|
Keymap,
|
|
4503
|
-
|
|
4501
|
+
stringifyKeySequence2 as stringifyKeySequence,
|
|
4502
|
+
stringifyKeyStroke2 as stringifyKeyStroke
|
|
4504
4503
|
};
|
|
4505
4504
|
|
|
4506
|
-
//# debugId=
|
|
4505
|
+
//# debugId=A921C8E17706FE5864756E2164756E21
|
|
4507
4506
|
//# sourceMappingURL=index.js.map
|