rethocker 0.1.0 → 0.1.1
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 +1 -1
- package/bin/rethocker-native +0 -0
- package/package.json +1 -1
- package/src/register-rule.ts +13 -7
- package/src/scripts/example.ts +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ const rk = rethocker([
|
|
|
23
23
|
remap: Key.escape,
|
|
24
24
|
},
|
|
25
25
|
|
|
26
|
-
// Remap
|
|
26
|
+
// Remap key to key, chord to key, key to chord, or even chord to chord (type any sequence you want)
|
|
27
27
|
// Use Key.* constants for autocomplete and safe string interpolation
|
|
28
28
|
{
|
|
29
29
|
key: "Ctrl+H E",
|
package/bin/rethocker-native
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/register-rule.ts
CHANGED
|
@@ -64,11 +64,6 @@ function registerRemap(
|
|
|
64
64
|
rule: RemapRule,
|
|
65
65
|
): RuleHandle {
|
|
66
66
|
const parsed = parseKey(rule.key);
|
|
67
|
-
if (parsed.kind === "sequence") {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`remap does not support sequences as trigger: "${rule.key}"`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
67
|
const target = parseKey(rule.remap);
|
|
73
68
|
const action =
|
|
74
69
|
target.kind === "sequence"
|
|
@@ -78,10 +73,21 @@ function registerRemap(
|
|
|
78
73
|
keyCode: target.combo.keyCode,
|
|
79
74
|
modifiers: target.combo.modifiers,
|
|
80
75
|
} as const);
|
|
81
|
-
|
|
76
|
+
|
|
77
|
+
if (parsed.kind === "single") {
|
|
78
|
+
return addRule(send, parsed.combo, action, {
|
|
79
|
+
id: rule.id,
|
|
80
|
+
conditions: buildConditions(rule),
|
|
81
|
+
disabled: rule.disabled,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Sequence trigger: intercept the full sequence then post the remap target
|
|
86
|
+
return addSequence(send, parsed.steps, action, {
|
|
82
87
|
id: rule.id,
|
|
83
|
-
conditions:
|
|
88
|
+
conditions: rule.conditions,
|
|
84
89
|
disabled: rule.disabled,
|
|
90
|
+
consume: true, // always consume — we're replacing the sequence
|
|
85
91
|
});
|
|
86
92
|
}
|
|
87
93
|
|
package/src/scripts/example.ts
CHANGED
|
@@ -20,9 +20,9 @@ const rk = rethocker([
|
|
|
20
20
|
remap: "escape",
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
//
|
|
23
|
+
// remap from a chord to a sequence of keys (chord to chord!)
|
|
24
24
|
key: "Ctrl+H E",
|
|
25
|
-
//
|
|
25
|
+
// use `Key` for autocomplete and typesafety
|
|
26
26
|
remap: `h e l l o Shift+n1 n1 ${Key.delete}`,
|
|
27
27
|
},
|
|
28
28
|
{
|