Moved the keymap upgrader to a top-level page like the power profiler to make it more discoverable. It upgrades more things than key codes now, so putting it in the codes category doesn't make much sense. Converted the upgrader code to TypeScript and split it up into smaller files to make it easier to add new upgrade functions. Added upgrade functions to remove/replace "label" properties and rename matrix-transform.h to matrix_transform.h.
25 lines
634 B
TypeScript
25 lines
634 B
TypeScript
import { createParser } from "./parser";
|
|
import { applyEdits } from "./textedit";
|
|
|
|
import { upgradeBehaviors } from "./behaviors";
|
|
import { upgradeHeaders } from "./headers";
|
|
import { upgradeKeycodes } from "./keycodes";
|
|
import { upgradeProperties } from "./properties";
|
|
|
|
export { initParser } from "./parser";
|
|
|
|
const upgradeFunctions = [
|
|
upgradeBehaviors,
|
|
upgradeHeaders,
|
|
upgradeKeycodes,
|
|
upgradeProperties,
|
|
];
|
|
|
|
export function upgradeKeymap(text: string) {
|
|
const parser = createParser();
|
|
const tree = parser.parse(text);
|
|
|
|
const edits = upgradeFunctions.map((f) => f(tree)).flat();
|
|
|
|
return applyEdits(text, edits);
|
|
}
|