diff --git a/.changeset/define-app-hotkeys-editor-speed.md b/.changeset/define-app-hotkeys-editor-speed.md new file mode 100644 index 000000000..3b3fc5b36 --- /dev/null +++ b/.changeset/define-app-hotkeys-editor-speed.md @@ -0,0 +1,10 @@ +--- +'@tanstack/hotkeys': patch +--- + +`defineAppHotkeys` no longer slows editors down. Typing a hotkey in a call with 300 declarations took up to 2 seconds per keystroke and now takes about 0.25 seconds, with the same hotkey and option checks and "Did you mean" suggestions. + +- A generic lookup such as `typeof appHotkeys[TId]` over spread-in app hotkeys no longer fails with "Expression produces a union type that is too complex to represent". +- A union of declaration objects no longer type-checks; call `defineAppHotkeys` in each branch instead. A generic function that passes its argument to `defineAppHotkeys` now type-checks. +- Completions list every chord while a hotkey is empty or doesn't yet form a chord. When the text already forms one, such as `'M'` or `'Mod+S'`, they list only that chord. +- `DefinedAppHotkeys` takes declarations of the new `AppHotkeyDeclaration` shape and no longer checks their hotkeys itself; `defineAppHotkeys` does. diff --git a/.intent/review-state.json b/.intent/review-state.json index 4f1aa1da6..24056c394 100644 --- a/.intent/review-state.json +++ b/.intent/review-state.json @@ -67,14 +67,14 @@ ] }, "skill:packages/hotkeys/skills/app-hotkeys/SKILL.md": { - "fingerprint": "429d527f33560a7d431b653761967e0ae9cc7ccdcca8f86136b53db07c02920c", + "fingerprint": "ded6e906fd3a322ce9e394f110aff8cd8966e085cafe5205a31e1533a87f7549", "snapshot": { "docs/framework/react/guides/app-hotkeys.md": "84085c3644fe0fbeab6fc4850866e26d75404d02fad7039336ac5555bdfb9f7a", "docs/framework/react/guides/cheat-sheet-ui-helpers.md": "a2c4c3add145ef9f04043edc7e2ca8b3fe07acdfea8c17144011da967ddfc318", "docs/framework/react/guides/custom-hotkey-recording.md": "4fe7986194e14c13976027c15164492bcdcea652e8379e3f0fe84fa5d84f4847", "packages/hotkeys/skills/app-hotkeys/SKILL.md": "454b7d1321a4f4d1a5aa4dd363466fb3acdd5f85935daa519768dc0a64622bcd", "packages/hotkeys/skills/app-hotkeys/references/recording.md": "742e56e73e58abfbbe354ab03abca29e3ebe08d79a84b43daf842b594d6e2b4c", - "packages/hotkeys/src/app-hotkeys.ts": "333fd70aa19406169d384344eba3339c8e757519f02e1a1df2d5c0758d0f1f85", + "packages/hotkeys/src/app-hotkeys.ts": "4620760d8409fb78a94319b6e52ca1a00c625121e29006fa1cef057fdeafa937", "packages/hotkeys/src/conflicts.ts": "3c8628500aee3e7ba14ec78411b5f5398fd66cbc00359ffdf227a81729a76fe5", "packages/hotkeys/src/hotkey-recorder.ts": "1b194de54bbd7d94c7a3ee581103651eed7077334adac55522ff499c951a2d2c", "packages/react-hotkeys/tests/skills/shortcut-settings/fixture.tsx": "ecc6155241ebccca4ef4cd76e8925b3abeec73e9d88e6906bdf70e4c604788aa", @@ -86,12 +86,11 @@ "packages/react-hotkeys/tests/skills/shortcut-settings/solution.tsx": "3441296dea51490188d34991428fe2b8bf11ce6fafbdf6e2f7595ff7082f1400", "packages/react-hotkeys/tests/skills/shortcut-settings/task.md": "7163ed96e6694c745461f0edaf296b353906cfdb868f9c5df7d08ee01a4ba0ea" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", - "outcome": "updated", - "reason": "Added a pitfall: split a large catalog with nested defineAppHotkeys calls rather than as const satisfies, and keep ids unique across files.", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", + "outcome": "no-change", + "reason": "Comment wording fix in app-hotkeys.ts (T[K] instead of TInput) and regenerated line numbers; no guidance change.", "evidence": [ - "packages/hotkeys/src/app-hotkeys.ts", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "Changed: packages/hotkeys/src/app-hotkeys.ts at 33e0b46f70957660418f1c76e9180c5badccd1fc" ] }, "skill:packages/hotkeys/skills/hotkeys-core/SKILL.md": { @@ -272,10 +271,10 @@ ] }, "planning:_artifacts": { - "fingerprint": "44450355cd9c53d46fad6e8d04fe598361ab0f4adefa46980f19913ee09f99e6", + "fingerprint": "082ccbff3ea83cd6f4d6fc41dd5d62376f54e94dbfa23a4fbf002b0e182700a6", "snapshot": { "_artifacts/domain_map.yaml": "fd7871cd1e1825435a188393cea39ee713f75265a07f7d2b05694881b01f1efe", - "_artifacts/skill_spec.md": "88f06cd2cdfe465571e7659db26c03d8e0df8e014126fa5165020b562d849123", + "_artifacts/skill_spec.md": "d77ed3bb07efdd8a167ae1b5ab08a23e1deba52832ad1bf1ea72625deb25082c", "_artifacts/skill_tree.yaml": "28586eb71e346a16cbaa064559562cb08199a684904db6dd0684251428afd35e", "docs/framework/alpine/guides/app-hotkeys.md": "9422d7d872521cc5fd2246b07408f10666790fa625fb78df519217b541873472", "docs/framework/alpine/quick-start.md": "822d70174d351fa7b2fe2e773b4fb3a2b558191386001025cdf2efac7b0c7854", @@ -333,7 +332,7 @@ "packages/hotkeys/skills/hotkeys-core/SKILL.md": "6a7f07c7d3d35af8c02dcc8835e97ae5a39ca498596665dd1e8894578d707062", "packages/hotkeys/skills/hotkeys-core/references/scopes.md": "1139da465c06e76ee1d489cb14fc3ce952011666b67f64855846805c241c2108", "packages/hotkeys/skills/hotkeys-core/references/testing.md": "c2957eaac34ca431832069156504cf7434dcb96d5227bcb7cbb2129dc8e979bd", - "packages/hotkeys/src/app-hotkeys.ts": "333fd70aa19406169d384344eba3339c8e757519f02e1a1df2d5c0758d0f1f85", + "packages/hotkeys/src/app-hotkeys.ts": "4620760d8409fb78a94319b6e52ca1a00c625121e29006fa1cef057fdeafa937", "packages/hotkeys/src/conflicts.ts": "3c8628500aee3e7ba14ec78411b5f5398fd66cbc00359ffdf227a81729a76fe5", "packages/hotkeys/src/hotkey-manager.ts": "787f629388c0fc5ef9b656efbc39efd18c62cbee0f96b7c0ef6673abc4c1f6fe", "packages/hotkeys/src/hotkey-recorder.ts": "1b194de54bbd7d94c7a3ee581103651eed7077334adac55522ff499c951a2d2c", @@ -403,12 +402,11 @@ "packages/vue-hotkeys/src/useHotkeyRecorder.ts": "f9090de677350d72ae3e1732eab11e5b89b5cf00021f2cc5e88d2fe3f2fb743d", "packages/vue-hotkeys/src/useHotkeys.ts": "219ded7bd27e250567817a9e74cb6c0032a58c1da6a6be81e820f4a67ab6c8c7" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", - "outcome": "updated", - "reason": "domain_map.yaml records the satisfies-instead-of-nested-defineAppHotkeys failure mode; skill_spec.md lists it and adds a source sync entry. skill_tree.yaml stays accurate.", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", + "outcome": "no-change", + "reason": "Comment wording fix in app-hotkeys.ts (T[K] instead of TInput) and regenerated line numbers; no guidance change.", "evidence": [ - "_artifacts/skill_spec.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "Changed: packages/hotkeys/src/app-hotkeys.ts at 33e0b46f70957660418f1c76e9180c5badccd1fc" ] }, "source:.changeset/intent-skills.md": { @@ -2042,14 +2040,17 @@ "evidence": ["docs/framework/vue/reference/index.md"] }, "source:docs/reference/index.md": { - "fingerprint": "2ecf3e96accb369c986bf9dd570765222de896693d8ccb68cecf800b92261751", + "fingerprint": "3b1bf23b23fa002260ffefe23d892183c3d8890c8998783d296faa57d1f6340c", "snapshot": { - "docs/reference/index.md": "8a42af31e99062cbbcc25a4c5cf2d666e98a71dd647d249f656311e0b339760f" + "docs/reference/index.md": "a75d8cd96aca75cc26c87731d147a49f88cc4203d804e87ca4ebc76b02230d8d" }, - "head": "f9fc17f0bbb537e70119ec81cec5d3d94294aa8e", - "outcome": "out-of-scope", - "reason": "Generated API reference pages; the skills cite guides and source, not reference pages", - "evidence": ["docs/reference/index.md"] + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", + "outcome": "no-change", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", + "evidence": [ + "docs/reference/index.md", + "packages/hotkeys: tsc, test:types and vitest (61 files, 2187 tests) pass; intent validate passed. Not run: fresh-consumer sessions." + ] }, "source:docs/reference/type-aliases/HotkeyRegistrationStatus.md": { "fingerprint": "4609753376173d2719336908a0b5d5dbc5d1dbbda35f4c5ce8b26206d294de8e", @@ -2374,107 +2375,107 @@ ] }, "source:docs/reference/classes/AppHotkeysStore.md": { - "fingerprint": "ee56a9dac570650aeb4c27efbc832fb750260d755269945d6130b5291b60402d", + "fingerprint": "d84486edbe660384188510ecce5ef429e7aad313a50cfa139d073ea6f355650a", "snapshot": { - "docs/reference/classes/AppHotkeysStore.md": "079967f338979e3a38a8dd909c5c5d0da988beebd91a9f7833b4c1a7a613a64f" + "docs/reference/classes/AppHotkeysStore.md": "a2350d227dd1a37cf461de1923b9f81537592e4c0ada6709008d23e09d867956" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/classes/AppHotkeysStore.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/defineAppHotkeys.md": { - "fingerprint": "80e2a561a7be5b46d63e0b95d39e1e07407624ac5f13c567537af40bf23eabbd", + "fingerprint": "75cf263168ec8559c878bf3f7fc02c9f6cd976fe690953ad6abd87537572d74a", "snapshot": { - "docs/reference/functions/defineAppHotkeys.md": "b929ce86f004a52d3a2bd67afe20a347a9ee30ca8c6fd89bd5773897499f2467" + "docs/reference/functions/defineAppHotkeys.md": "026234adb7afc9d0e570c67fb785889f24126b8d49d83d0097bedfc854f9d305" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/defineAppHotkeys.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/getAppHotkeyRegistrationOptions.md": { - "fingerprint": "d1cdcd266808e9eff6833076fbc8ae0c5b82f0d27949e76d22c94875862c0333", + "fingerprint": "d046aad7d2020ba83de4fb509c59f58f59e519fc70f3a8503a3b513c47b6cc6e", "snapshot": { - "docs/reference/functions/getAppHotkeyRegistrationOptions.md": "000a1a1a3ecc7ebdd9d3a0facb410489a87b3212285467fca60436ba9dc34a36" + "docs/reference/functions/getAppHotkeyRegistrationOptions.md": "42ce9c142ca8424ad37234620840d91139b1597878e3108518ad008c6cdbb128" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/getAppHotkeyRegistrationOptions.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/isAppHotkey.md": { - "fingerprint": "fb2f5aca7fc13ac36946371e08713d6b22be5583c9c4017b638f31cf823be5c6", + "fingerprint": "b3e2456894230cd0639a5dbfcd1ce4c53452ca6daa11df2443730aa9952a89c6", "snapshot": { - "docs/reference/functions/isAppHotkey.md": "437cf972cec1f57f8fe715ccb8bffeda3a2127198228f34889d1104633419153" + "docs/reference/functions/isAppHotkey.md": "0c65ec4b24aaf3560ec8775fc35d948951fed6b8a8d9c207725d9617353a2649" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/isAppHotkey.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/isCustomHotkey.md": { - "fingerprint": "007cbf70d6ddb9966b15209435541f1d3cc15d3f28fa0da6c2fa872968d535c0", + "fingerprint": "a267b0db632485574ea3ac21b6895c30eddb9841450e078ffd6b28f4b0952719", "snapshot": { - "docs/reference/functions/isCustomHotkey.md": "2d9507868acbd371fbcbc45b7c2dd9b6fea7a5be2a9077fbd3be239eb4feedc1" + "docs/reference/functions/isCustomHotkey.md": "faf079ab8b961f7c10f2f661b562846d768267189776b0155040ce370799571a" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/isCustomHotkey.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/provideAppHotkeys.md": { - "fingerprint": "0e236bb72e70f8a008dafa46ceb9e48a25a550989b4db44c62eaffe2cb8d30c0", + "fingerprint": "008109335e950767aafbdfec20376ccf315dba613b8eb5309dec31bb632d5e74", "snapshot": { - "docs/reference/functions/provideAppHotkeys.md": "5771fe0131ddb9f32d996cd2adee709912e2aae04fd952b21a4329e277e67d89" + "docs/reference/functions/provideAppHotkeys.md": "434e7208652c65344ff88f7ab32b123589e0e4345a4a396f53cc76ba65321331" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/provideAppHotkeys.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/publishAppHotkeysStore.md": { - "fingerprint": "3c192748840a54520d62cffb4845c426202ce6624663e3a33f84e8d1d0bb287e", + "fingerprint": "50808c659800df6e63382b1efe319d1693d76d2f8ad5bfc022f27fa15786a5cd", "snapshot": { - "docs/reference/functions/publishAppHotkeysStore.md": "022fb9347d729f48e13529347183da2b5202c84c529a31e070a60276ff6d1277" + "docs/reference/functions/publishAppHotkeysStore.md": "582645f6efc2e81c4a6499b4fc141c67ce49a04a4f0c49d12cbbf91ec7dae6fc" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/publishAppHotkeysStore.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/resolveAppHotkey.md": { - "fingerprint": "b4cb90d940fa282f9a1ed751bfbee7d7fb509240b0f209301bebaa864f0eb092", + "fingerprint": "4814c7a103b93b2cc44b724bc301a46fa4360c42e3fb8820cddfb67b69dd5e40", "snapshot": { - "docs/reference/functions/resolveAppHotkey.md": "1297982241a19b1d661f714fa8526be12ab026d90ae3e03223008c200410230c" + "docs/reference/functions/resolveAppHotkey.md": "64a4465e7981054c233b0e0b16054dd275ce76af00df8940e6f734de27f86ebb" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/resolveAppHotkey.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/interfaces/AppHotkey.md": { @@ -2498,42 +2499,42 @@ "evidence": ["Core 2,001 tests, adapter suites, e2e"] }, "source:docs/reference/interfaces/AppHotkeyListItem.md": { - "fingerprint": "5b034f6b32a4469ad5ef57c619325fe9b4de58ab578d0625d47edb927d59ba4c", + "fingerprint": "59accd606e827146665304bc2639406a047be8ff8418bab308625e4805387b86", "snapshot": { - "docs/reference/interfaces/AppHotkeyListItem.md": "4154af1d72bab146c1b5a9076898514ca947e43bc66d9a14753b2c507b9735b8" + "docs/reference/interfaces/AppHotkeyListItem.md": "057f6ed320f5170de206b400113848abd898a8a0f2d240c61d0a7eb96ed1bbfd" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/interfaces/AppHotkeyListItem.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/interfaces/AppHotkeysState.md": { - "fingerprint": "10db17d25258323cd89f2d9831d0ce8b0f339c939f2bdcd06f9cf5b334c757c5", + "fingerprint": "70400306206dc34500d6bb17d5677eef23da1d04911597f6324b91ea7debf56e", "snapshot": { - "docs/reference/interfaces/AppHotkeysState.md": "155c058a995b5eb320511913bb3cd1d2d04d73080f8c48e838152c898d3287f9" + "docs/reference/interfaces/AppHotkeysState.md": "44a178f7adb81c111b1de5d10fdb9cc4ab0e1fc10f60ebc6bc4d962aa6cd0905" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/interfaces/AppHotkeysState.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/interfaces/AppHotkeysStoreOptions.md": { - "fingerprint": "d6f4f1caa6d233b83eaa97cb98f167c7b050056bb83fcb24f6f1b2187b94b8e0", + "fingerprint": "045c130b0d9fc40702a451cbe149010ec23a5d835076b0957d14fb91eacbf270", "snapshot": { - "docs/reference/interfaces/AppHotkeysStoreOptions.md": "1acb0dc68432c76499a52973f50c68dab0da953169b69635e1a8fe1c20d0a1e5" + "docs/reference/interfaces/AppHotkeysStoreOptions.md": "b1db3dbde6d569c19cab2c6593f27ab2626ceaf8c145510370556f8500ec438f" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/interfaces/AppHotkeysStoreOptions.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/interfaces/Register.md": { @@ -2557,29 +2558,29 @@ "evidence": ["Core 2,001 tests, adapter suites, e2e"] }, "source:docs/reference/type-aliases/AppHotkeyDefaultKind.md": { - "fingerprint": "812ec8a724e43cb03193f538d5ea3021a5c5b13ea063353aca247c6b41948f08", + "fingerprint": "c01c94324842eb97528a484e8ef472b029df269b1107e8fdb38346459deba674", "snapshot": { - "docs/reference/type-aliases/AppHotkeyDefaultKind.md": "fc164a543295563aa83216c9e43c067ee1d59d3b2544ff63c52dddb254ccd0f8" + "docs/reference/type-aliases/AppHotkeyDefaultKind.md": "4ff9de0cee1ef06cc8244cf7ab315f311e1746581980e363be47ca7ab8e511e9" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/AppHotkeyDefaultKind.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/AppHotkeyId.md": { - "fingerprint": "8d7b0bf64dc3eb03b63e6987585722533d69079001cc2cd0982840fa01227859", + "fingerprint": "1da9134bdfd40d0d64949a7715969bcbf350add5fca58c6eb37c51bd0f2e958b", "snapshot": { - "docs/reference/type-aliases/AppHotkeyId.md": "eec5b6f35e5fdcf661e3b58752b102c2469f514349318f5c51c01228d5fc4a81" + "docs/reference/type-aliases/AppHotkeyId.md": "96d726c0200973754b6810a0b1a9a9e24586f2713fa8a93407a2fdd56423353e" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/AppHotkeyId.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/AppHotkeyOptions.md": { @@ -2603,16 +2604,16 @@ "evidence": ["Core 2,001 tests, adapter suites, e2e"] }, "source:docs/reference/type-aliases/AppHotkeyStatus.md": { - "fingerprint": "9682045bee188c5f57e5519dd15264185547390899188f2e3c6690fb6d6039d6", + "fingerprint": "66c3ad414a6762e20074be9eadc476f587d3e0043e76a16dd770a0f9932464a5", "snapshot": { - "docs/reference/type-aliases/AppHotkeyStatus.md": "62b1af9fda054f775813e56b0d260a7d51b92f87f38363569b399b2b95b7ea46" + "docs/reference/type-aliases/AppHotkeyStatus.md": "b9a9c2320256728e5aafadbd924a71c25b723ba6a41c460cbdc4333f3a263a94" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/AppHotkeyStatus.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/AppHotkeys.md": { @@ -2626,42 +2627,42 @@ "evidence": ["Core 2,001 tests, adapter suites, e2e"] }, "source:docs/reference/type-aliases/CustomHotkeys.md": { - "fingerprint": "9a5fc3348f198fb2e1f96c0155ad21132540584b44c6ec797c94c571e0005461", + "fingerprint": "894d3013de237860b0304fe4f3a146b99c0848350440d04de7229e99b215a006", "snapshot": { - "docs/reference/type-aliases/CustomHotkeys.md": "907ae0aae55fd2895fb76f48ee6576a2c4026f7e1e09ce2c77535a592b003e2a" + "docs/reference/type-aliases/CustomHotkeys.md": "07900510be0094120920c7150203bfbd1ce4ee280cc1ae2144b2d1c7cb6768be" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/CustomHotkeys.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/DefinedAppHotkeys.md": { - "fingerprint": "a2e7d49a67416a25643d5cd0008edbc344083b95ff1b43a11912a363887bd28d", + "fingerprint": "faa9efeefbce24a5decb5fb0c5e8cb6728a3c1687245a90a3b53981978e60e5c", "snapshot": { - "docs/reference/type-aliases/DefinedAppHotkeys.md": "7b2d83701acf751f5001eb8dce27243d6ec91960a8b505f081f47c6797551483" + "docs/reference/type-aliases/DefinedAppHotkeys.md": "66b2d93e1226490bee1156723e9293ca8fe36259f8ddafcabf1eefb4771d5da2" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/DefinedAppHotkeys.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/RegisteredAppHotkeys.md": { - "fingerprint": "73a267466a36538eaaef69be25decf7c0ef8cc9fd2624cbb7df3c04d913b32a4", + "fingerprint": "4fb993fc7659483115423163d751d4612104ff16fda10981077b10967055d880", "snapshot": { - "docs/reference/type-aliases/RegisteredAppHotkeys.md": "c4187a8a17557a6c6bb49107f566de6abc6f7e0ef5227dd33ad2c7610b41badf" + "docs/reference/type-aliases/RegisteredAppHotkeys.md": "e8b58bcbdd9c668f1aaced2fcc9af133b4d6c1276792abd173bbd6ac7672f5b6" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/RegisteredAppHotkeys.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/Target.md": { @@ -7222,16 +7223,16 @@ ] }, "source:packages/hotkeys/tests/app-hotkeys.test.ts": { - "fingerprint": "6b89915683d4a502580c0130d47e46c954ac096628fc49d07a5b17c38e3e1659", + "fingerprint": "e6af6607e15154f930f87398ab4f8b6376304886c64c7d660ba8941e4604fa4a", "snapshot": { - "packages/hotkeys/tests/app-hotkeys.test.ts": "3f616bef3f18f2cc2ec5e41078eb3e443d3ca21e4f1909f9a4bb37b844f314b4" + "packages/hotkeys/tests/app-hotkeys.test.ts": "73d47bec544b7f01af2eca56abd37b6d2dbe47080870fcb7802080ce486ead8d" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Tests for spread-in app hotkeys; no skill covers test files.", + "reason": "Tests for editor latency, conditional and nullable hotkeys, and the generic id lookup; no skill covers test files.", "evidence": [ "packages/hotkeys/tests/app-hotkeys.test.ts", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:packages/hotkeys/tests/unset-values.test.ts": { @@ -19798,16 +19799,16 @@ "evidence": ["packages/hotkeys/tests/typed-keys.ts"] }, "source:packages/hotkeys/tests/app-hotkeys-type-performance.test.ts": { - "fingerprint": "894957d778d6efe08acc11f276569cc60190427e73f5cd351c23ab98b0da2bc5", + "fingerprint": "c69476942997a0a4977fb37b7372406ca073ff7d466650e60ce9c4a05456c774", "snapshot": { - "packages/hotkeys/tests/app-hotkeys-type-performance.test.ts": "2eb25fec571f622b36fb8860a0d434cc661a311ad64babff8e655fbb94f926ad" + "packages/hotkeys/tests/app-hotkeys-type-performance.test.ts": "091c31810246de92d1cde1c53262fd558569df081a3018a524aa77ad3b219f06" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Tests for spread-in app hotkeys; no skill covers test files.", + "reason": "Tests for editor latency, the generic id lookup, and the factory test argument type; no skill covers test files.", "evidence": [ "packages/hotkeys/tests/app-hotkeys-type-performance.test.ts", - "packages/hotkeys vitest run: 61 files, 2186 tests passed; test:types passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc, test:types and vitest (61 files, 2187 tests) pass; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:packages/vue-hotkeys/tests/composable-types.test.ts": { @@ -19831,16 +19832,16 @@ "evidence": ["packages/vue-hotkeys/tests/provider-types.test.ts"] }, "source:docs/reference/interfaces/RecordedKeyPresses.md": { - "fingerprint": "04d5eae9a2c60068a8cbb73cedb7521338edb090f86d965c5d858b58e34d6cf1", + "fingerprint": "7a2c138cebb26e60cd7d4a819fe4d220e3b8ab8a64838c3706b2336adeafe4f7", "snapshot": { - "docs/reference/interfaces/RecordedKeyPresses.md": "06e7e15e1ec72f96298450f4a97feb2994c16f324bb085cc62b9fb24f170f077" + "docs/reference/interfaces/RecordedKeyPresses.md": "53d685e78bd43730d4c44bd5fd5608e9adaed4cf5078968ab45e80cd74f2c9e8" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/interfaces/RecordedKeyPresses.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:e2e/layouts/alt-graph.spec.ts": { @@ -21252,16 +21253,16 @@ ] }, "source:docs/reference/interfaces/CustomHotkeyActions.md": { - "fingerprint": "b391107f8db3eefa6fcfe2ee651c96b8ddcd01e211b62b5f016cdc5a651c1450", + "fingerprint": "6f38f1555c6ba60330a94e2564a4984e6fbbbe30ce42aeb4f35b677f2e167712", "snapshot": { - "docs/reference/interfaces/CustomHotkeyActions.md": "f0120a977c54b9a79fa77222d2633fd6542e6722c5c606dda17c613cc2997bab" + "docs/reference/interfaces/CustomHotkeyActions.md": "1adb3ddd22f71a346cfc8847869c3eb83ead79210316b27ffc2a7f39e5abb39f" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/interfaces/CustomHotkeyActions.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/interfaces/HotkeyRecorderActions.md": { @@ -21336,16 +21337,16 @@ ] }, "source:docs/reference/type-aliases/RegisteredAppHotkeyListItem.md": { - "fingerprint": "84375491c9ba7bb738b24626ab3375a1e0e78fb0ad710438b0deabe60687a07e", + "fingerprint": "14a3bd60f535f528ce4aff34862dd8e7cb4b2ea214f3b52d4e292996defc8327", "snapshot": { - "docs/reference/type-aliases/RegisteredAppHotkeyListItem.md": "8a96cfc9ce16e1fc5e283bde668d3ebf323e462d8fa60d7dc16ad6f04648aae1" + "docs/reference/type-aliases/RegisteredAppHotkeyListItem.md": "5242e1fb376e9d82349e8d63f3e3d9a5c5deacb51e7c1287976c513d6d4c655c" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/type-aliases/RegisteredAppHotkeyListItem.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/type-aliases/ResolvableModifier.md": { @@ -21605,41 +21606,42 @@ "evidence": ["Core, adapter and e2e suites; battery 159/159"] }, "source:docs/reference/adapter/functions/installAppHotkeysStore.md": { - "fingerprint": "38ee274c9fdb96e725f794d21202c8a3ba318ca5a7568a00a9d6f10ffd894f55", + "fingerprint": "f286d0df7765d5ba1bdea552ca95b7eb004c0636ef0826312ac12b64ce6dedaf", "snapshot": { - "docs/reference/adapter/functions/installAppHotkeysStore.md": "d5f8ea49cfeae36b40aeb7164fe0de97b3b0a2f14137c322d7283be2bf0ed8ed" + "docs/reference/adapter/functions/installAppHotkeysStore.md": "ed1a892584538383a4080d585919038891ba96e4eb3bda038e8f083e41dfa3bd" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/adapter/functions/installAppHotkeysStore.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:docs/reference/functions/installAppHotkeysStore.md": { - "fingerprint": "ffd3460b765d7f436361a643f1f39241fa3f5789be87b02adad577db4bea01ad", + "fingerprint": "dba5511e27f9abc55ab7fb7622110fb6b149c9c8ff492b352d599653bebcbb02", "snapshot": { - "docs/reference/functions/installAppHotkeysStore.md": "d5f8ea49cfeae36b40aeb7164fe0de97b3b0a2f14137c322d7283be2bf0ed8ed" + "docs/reference/functions/installAppHotkeysStore.md": "ed1a892584538383a4080d585919038891ba96e4eb3bda038e8f083e41dfa3bd" }, - "head": "00217cf3f2b203d406d1097656f2275156026943", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Generated by pnpm generate-docs; the DefinedAppHotkeys doc text and line numbers changed. Guidance reviewed under app-hotkeys.", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", "evidence": [ "docs/reference/functions/installAppHotkeysStore.md", - "packages/hotkeys tests and types pass; pnpm test:pr 317/317 tasks passed; intent validate passed. Not run: fresh-consumer sessions." + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:packages/hotkeys/tests/app-hotkeys-factory.test.ts": { - "fingerprint": "be094b2d055590a9f30a13eb115c9f53aac4df238dfa8e855b4d8ecccdfeeae5", + "fingerprint": "266f273049ca09c4daaa812832ed904aee0b83462824d70d2d473be45f50c51b", "snapshot": { - "packages/hotkeys/tests/app-hotkeys-factory.test.ts": "73bf42d597dd09dc872f4b5908526f98e82aecd4682c052b2ef7f7a67a5b74cb" + "packages/hotkeys/tests/app-hotkeys-factory.test.ts": "6e7f4156069d9f3a67868d0a0cfca08d3ecb77910c63800a5237c4fc0366d1b1" }, - "head": "fb6af948672bc43c0c35414df41bb63724a85e97", + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", "outcome": "no-change", - "reason": "Guide or config change for the meta update rule or AppHotkeysProvider; the affected skills were updated.", + "reason": "Tests for editor latency, the generic id lookup, and the factory test argument type; no skill covers test files.", "evidence": [ - "Diff of packages/hotkeys/tests/app-hotkeys-factory.test.ts against origin/main." + "packages/hotkeys/tests/app-hotkeys-factory.test.ts", + "packages/hotkeys: tsc, test:types and vitest (61 files, 2187 tests) pass; intent validate passed. Not run: fresh-consumer sessions." ] }, "source:packages/react-hotkeys/tests/server-app-hotkeys.test.tsx": { @@ -25987,6 +25989,31 @@ "packages/hotkeys/tests/trigger.test.ts", "pnpm -C packages/hotkeys exec vitest run (all passed, including tests/trigger.test.ts); intent validate packages/hotkeys/skills passed. Not run: fresh-consumer sessions." ] + }, + "source:docs/reference/interfaces/AppHotkeyDeclaration.md": { + "fingerprint": "9337cf4d7d91c32f15c58c4d1f49c7c52de6b19afea579f57be9d9e09a52410a", + "snapshot": { + "docs/reference/interfaces/AppHotkeyDeclaration.md": "2112d1554c713ecbae5ac6755de0e40a6a0a57c3a31bc8a69ad33602aee57727" + }, + "head": "33e0b46f70957660418f1c76e9180c5badccd1fc", + "outcome": "no-change", + "reason": "Generated by pnpm generate-docs from the changed app-hotkeys.ts: line numbers, the new AppHotkeyDeclaration page, and the defineAppHotkeys and DefinedAppHotkeys docs. Guidance reviewed under app-hotkeys.", + "evidence": [ + "docs/reference/interfaces/AppHotkeyDeclaration.md", + "packages/hotkeys: tsc and vitest (62 files, 2190 tests) pass; Supabase Studio typecheck and 1196 tests pass with the build; intent validate passed. Not run: fresh-consumer sessions." + ] + }, + "source:packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts": { + "fingerprint": "9f0c800b66e1cc4e2fd9a65a898a06dadea0b8e0f062c317a05245ffcfc0f5e0", + "snapshot": { + "packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts": "9e8673aca942c61d2dc48029602074af8042780d0945c54b4114a63150d93334" + }, + "head": "797b66878a61cc10483f987bc94e207d13fa5667", + "outcome": "no-change", + "reason": "Latency test made lighter for CI: fewer runs, longer timeout, 4x threshold; no guidance change.", + "evidence": [ + "Changed: packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts at 797b66878a61cc10483f987bc94e207d13fa5667" + ] } } } diff --git a/_artifacts/skill_spec.md b/_artifacts/skill_spec.md index ba9462946..5fa1cdc69 100644 --- a/_artifacts/skill_spec.md +++ b/_artifacts/skill_spec.md @@ -224,3 +224,9 @@ The skills teach agents to use those APIs directly. The core skills hold the fra - **Source:** branch `feat/nested-app-hotkeys` from `00217cf3`. `defineAppHotkeys` accepts the app hotkeys of another `defineAppHotkeys` call. Spread-in entries keep their id and the kind of their default, and skip the option check that their own call already ran. An entry that replaces a spread-in `hotkey` or `options` is checked like any other declaration. Types only; no runtime change. - **Changes:** `app-hotkeys` gains a pitfall: split a large catalog with nested `defineAppHotkeys` calls instead of `as const satisfies Record`, which defers the kind-specific option check to the final call. Every framework's `app-hotkeys.md` guide gains a "Split declarations across files" section. `domain_map.yaml` records the failure mode. Framework skills and `skill_tree.yaml` are unchanged: no framework skill shows split declarations. - **Checks:** `packages/hotkeys/tests/app-hotkeys.test.ts` covers spread-in types, a renamed entry, and option errors beside spread-in entries; `app-hotkeys-type-performance.test.ts` spreads 100 entries. `intent validate` passes. Not run: fresh-consumer sessions. + +### Source sync — 2026-11-29 — defineAppHotkeys editor speed + +- **Source:** branch `perf/define-app-hotkeys-editor` from `33e0b46f`. `defineAppHotkeys` infers declarations against `AppHotkeyDeclaration`, which names no hotkey union, and checks each hotkey once the declarations are inferred. Typing in a 300-entry call drops from about 2 seconds per keystroke to about 0.25 seconds, with the same errors and suggestions. Completions list only the current text once it forms a chord, such as `'M'`. A generic lookup such as `typeof appHotkeys[TId]` over spread-in app hotkeys no longer fails with TS2590. A union of declaration objects no longer type-checks. +- **Changes:** none to skills or `domain_map.yaml`. No skill shows a union of declaration objects, and the `app-hotkeys` pitfall about nested `defineAppHotkeys` calls stays accurate. `skill_tree.yaml` is unchanged. +- **Checks:** `packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts` compares editor latency with `as const satisfies`; `app-hotkeys-type-performance.test.ts` covers the generic lookup. `intent validate` passes. Not run: fresh-consumer sessions. diff --git a/docs/reference/adapter/functions/installAppHotkeysStore.md b/docs/reference/adapter/functions/installAppHotkeysStore.md index 332d401d1..9cedf5a46 100644 --- a/docs/reference/adapter/functions/installAppHotkeysStore.md +++ b/docs/reference/adapter/functions/installAppHotkeysStore.md @@ -9,7 +9,7 @@ title: installAppHotkeysStore function installAppHotkeysStore(): void; ``` -Defined in: [app-hotkeys.ts:230](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L230) +Defined in: [app-hotkeys.ts:360](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L360) Lets providers in this bundle create stores for app hotkeys. `defineAppHotkeys` calls it. Adapters call it where the declarations can diff --git a/docs/reference/classes/AppHotkeysStore.md b/docs/reference/classes/AppHotkeysStore.md index 446c836f4..f82711111 100644 --- a/docs/reference/classes/AppHotkeysStore.md +++ b/docs/reference/classes/AppHotkeysStore.md @@ -5,7 +5,7 @@ title: AppHotkeysStore -Defined in: [app-hotkeys.ts:482](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L482) +Defined in: [app-hotkeys.ts:612](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L612) Holds declared app hotkeys and the user's custom hotkeys. Framework providers create one and expose it through hooks; devtools read it from @@ -36,7 +36,7 @@ store.setCustomHotkey('doc.save', 'Mod+Shift+S') new AppHotkeysStore(appHotkeys, options?): AppHotkeysStore; ``` -Defined in: [app-hotkeys.ts:489](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L489) +Defined in: [app-hotkeys.ts:619](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L619) #### Parameters @@ -60,7 +60,7 @@ Defined in: [app-hotkeys.ts:489](https://github.com/TanStack/hotkeys/blob/main/p readonly store: Store>; ``` -Defined in: [app-hotkeys.ts:483](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L483) +Defined in: [app-hotkeys.ts:613](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L613) ## Accessors @@ -72,7 +72,7 @@ Defined in: [app-hotkeys.ts:483](https://github.com/TanStack/hotkeys/blob/main/p get appHotkeys(): T; ``` -Defined in: [app-hotkeys.ts:508](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L508) +Defined in: [app-hotkeys.ts:638](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L638) Effective app hotkeys. @@ -90,7 +90,7 @@ Effective app hotkeys. get customHotkeys(): CustomHotkeys; ``` -Defined in: [app-hotkeys.ts:513](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L513) +Defined in: [app-hotkeys.ts:643](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L643) The user's hotkeys that differ from the defaults. @@ -113,7 +113,7 @@ findConflicts( | null>[]; ``` -Defined in: [app-hotkeys.ts:602](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L602) +Defined in: [app-hotkeys.ts:732](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L732) Other app hotkeys that would collide if `id` used `hotkey`. App hotkeys collide when their scopes match or either is `'global'`, and their @@ -169,7 +169,7 @@ get(id): | undefined; ``` -Defined in: [app-hotkeys.ts:577](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L577) +Defined in: [app-hotkeys.ts:707](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L707) Effective app hotkey for an id, or `undefined` when it is not declared. @@ -195,7 +195,7 @@ Effective app hotkey for an id, or `undefined` when it is not declared. getList(registrations): AppHotkeyListItem[]; ``` -Defined in: [app-hotkeys.ts:687](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L687) +Defined in: [app-hotkeys.ts:817](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L817) Joins app hotkeys with live registrations, in declaration order. Adapters call this with the manager's registration views. @@ -218,7 +218,7 @@ Adapters call this with the manager's registration views. resetCustomHotkey(id): void; ``` -Defined in: [app-hotkeys.ts:664](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L664) +Defined in: [app-hotkeys.ts:794](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L794) Restores the default hotkey for an app hotkey. @@ -240,7 +240,7 @@ keyof `T` & `string` resetCustomHotkeys(): void; ``` -Defined in: [app-hotkeys.ts:671](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L671) +Defined in: [app-hotkeys.ts:801](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L801) Restores every default hotkey. @@ -256,7 +256,7 @@ Restores every default hotkey. setAppHotkeys(appHotkeys): void; ``` -Defined in: [app-hotkeys.ts:563](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L563) +Defined in: [app-hotkeys.ts:693](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L693) Replaces the declarations, for example after hot module replacement. Custom hotkeys for ids that still exist are kept. @@ -286,7 +286,7 @@ setCustomHotkey( | null>[]; ``` -Defined in: [app-hotkeys.ts:630](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L630) +Defined in: [app-hotkeys.ts:760](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L760) Sets the user's hotkey for an app hotkey. `null` unbinds it. A hotkey equal to the default removes the customization. Pass the recorder's @@ -325,7 +325,7 @@ hotkey, such as `''`, and both return an empty array. setOptions(options): void; ``` -Defined in: [app-hotkeys.ts:527](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L527) +Defined in: [app-hotkeys.ts:657](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L657) Updates options. Providers call it with their props on every update. diff --git a/docs/reference/functions/defineAppHotkeys.md b/docs/reference/functions/defineAppHotkeys.md index 55afd32df..cc730fa1a 100644 --- a/docs/reference/functions/defineAppHotkeys.md +++ b/docs/reference/functions/defineAppHotkeys.md @@ -9,23 +9,28 @@ title: defineAppHotkeys function defineAppHotkeys(definitions): DefinedAppHotkeys; ``` -Defined in: [app-hotkeys.ts:205](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L205) +Defined in: [app-hotkeys.ts:333](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L333) Declares every app hotkey up front, without registering any, so cheat sheets and settings screens can list hotkeys whose components have not mounted. Pass the result to `HotkeysProvider` as `appHotkeys`. +Spread the results of other `defineAppHotkeys` calls to combine +declarations from several files. To pick declarations at runtime, call +`defineAppHotkeys` in each branch: a union of declaration objects doesn't +type-check. + ## Type Parameters ### T -`T` *extends* `Record`\<`string`, [`AppHotkeyInput`](../interfaces/AppHotkeyInput.md)\> +`T` *extends* `Record`\<`string`, [`AppHotkeyDeclaration`](../interfaces/AppHotkeyDeclaration.md)\> ## Parameters ### definitions -`T` & `ValidatedAppHotkeyInputs`\<`T`\> +`ValidatedAppHotkeyInputs`\<`T`\> ## Returns diff --git a/docs/reference/functions/getAppHotkeyRegistrationOptions.md b/docs/reference/functions/getAppHotkeyRegistrationOptions.md index d32982d30..f66cbe2b0 100644 --- a/docs/reference/functions/getAppHotkeyRegistrationOptions.md +++ b/docs/reference/functions/getAppHotkeyRegistrationOptions.md @@ -9,7 +9,7 @@ title: getAppHotkeyRegistrationOptions function getAppHotkeyRegistrationOptions(appHotkey): AppHotkeyChordOptions & AppHotkeySequenceOptions & object; ``` -Defined in: [app-hotkeys.ts:739](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L739) +Defined in: [app-hotkeys.ts:869](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L869) Options that adapters pass to the manager when registering an app hotkey: declared options, scope, meta, and the app hotkey id. The manager drops options diff --git a/docs/reference/functions/installAppHotkeysStore.md b/docs/reference/functions/installAppHotkeysStore.md index 332d401d1..9cedf5a46 100644 --- a/docs/reference/functions/installAppHotkeysStore.md +++ b/docs/reference/functions/installAppHotkeysStore.md @@ -9,7 +9,7 @@ title: installAppHotkeysStore function installAppHotkeysStore(): void; ``` -Defined in: [app-hotkeys.ts:230](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L230) +Defined in: [app-hotkeys.ts:360](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L360) Lets providers in this bundle create stores for app hotkeys. `defineAppHotkeys` calls it. Adapters call it where the declarations can diff --git a/docs/reference/functions/isAppHotkey.md b/docs/reference/functions/isAppHotkey.md index f49e8b986..428b4cb8e 100644 --- a/docs/reference/functions/isAppHotkey.md +++ b/docs/reference/functions/isAppHotkey.md @@ -9,7 +9,7 @@ title: isAppHotkey function isAppHotkey(value): value is AppHotkey; ``` -Defined in: [app-hotkeys.ts:237](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L237) +Defined in: [app-hotkeys.ts:367](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L367) Whether a value is an app hotkey created by `defineAppHotkeys`. diff --git a/docs/reference/functions/isCustomHotkey.md b/docs/reference/functions/isCustomHotkey.md index cec51df0d..d23f599ad 100644 --- a/docs/reference/functions/isCustomHotkey.md +++ b/docs/reference/functions/isCustomHotkey.md @@ -9,7 +9,7 @@ title: isCustomHotkey function isCustomHotkey(appHotkey, platform?): boolean; ``` -Defined in: [app-hotkeys.ts:255](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L255) +Defined in: [app-hotkeys.ts:385](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L385) Whether an app hotkey's effective hotkey differs from its default. diff --git a/docs/reference/functions/provideAppHotkeys.md b/docs/reference/functions/provideAppHotkeys.md index 28005d31d..0716ee113 100644 --- a/docs/reference/functions/provideAppHotkeys.md +++ b/docs/reference/functions/provideAppHotkeys.md @@ -9,7 +9,7 @@ title: provideAppHotkeys function provideAppHotkeys(appHotkeys, options?): object; ``` -Defined in: [app-hotkeys.ts:786](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L786) +Defined in: [app-hotkeys.ts:916](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L916) Creates an app hotkeys store and publishes it on the HotkeyManager, for adapters without a provider component (such as Lit and Alpine). Hotkey diff --git a/docs/reference/functions/publishAppHotkeysStore.md b/docs/reference/functions/publishAppHotkeysStore.md index 4ef3d19d8..cee7cd149 100644 --- a/docs/reference/functions/publishAppHotkeysStore.md +++ b/docs/reference/functions/publishAppHotkeysStore.md @@ -9,7 +9,7 @@ title: publishAppHotkeysStore function publishAppHotkeysStore(store): () => void; ``` -Defined in: [app-hotkeys.ts:760](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L760) +Defined in: [app-hotkeys.ts:890](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L890) Publishes a provider's store on the HotkeyManager so devtools can list declared hotkeys. Returns a cleanup function that unpublishes it if it is diff --git a/docs/reference/functions/resolveAppHotkey.md b/docs/reference/functions/resolveAppHotkey.md index 890dfc3e9..34d23c264 100644 --- a/docs/reference/functions/resolveAppHotkey.md +++ b/docs/reference/functions/resolveAppHotkey.md @@ -9,7 +9,7 @@ title: resolveAppHotkey function resolveAppHotkey(appHotkey, store): AppHotkey; ``` -Defined in: [app-hotkeys.ts:727](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L727) +Defined in: [app-hotkeys.ts:857](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L857) Returns the provider's version of an app hotkey, so custom hotkeys apply even when a component imports the declaration directly. Falls back to the diff --git a/docs/reference/index.md b/docs/reference/index.md index 4c90c5504..11c665f9e 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -16,6 +16,7 @@ title: "@tanstack/hotkeys" - [ActivateHotkeyScopeOptions](interfaces/ActivateHotkeyScopeOptions.md) - [AppHotkey](interfaces/AppHotkey.md) +- [AppHotkeyDeclaration](interfaces/AppHotkeyDeclaration.md) - [AppHotkeyInput](interfaces/AppHotkeyInput.md) - [AppHotkeyListItem](interfaces/AppHotkeyListItem.md) - [AppHotkeysState](interfaces/AppHotkeysState.md) diff --git a/docs/reference/interfaces/AppHotkeyDeclaration.md b/docs/reference/interfaces/AppHotkeyDeclaration.md new file mode 100644 index 000000000..2f27d03e2 --- /dev/null +++ b/docs/reference/interfaces/AppHotkeyDeclaration.md @@ -0,0 +1,70 @@ +--- +id: AppHotkeyDeclaration +title: AppHotkeyDeclaration +--- + + + +Defined in: [app-hotkeys.ts:137](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L137) + +The shape of a declaration before `defineAppHotkeys` checks its hotkey and +options. `DefinedAppHotkeys` takes a map of these. + +It names no hotkey type on purpose. While TypeScript infers the +declarations, it checks every literal in the call against contextual types +built from this shape, and each check walks any union it finds. With the +chord union (thousands of members) here, each keystroke in a large +declaration took seconds in editors. `ValidatedAppHotkeyInputs` checks each +hotkey once the declarations are inferred. + +## Properties + +### hotkey + +```ts +hotkey: string | readonly string[] | UncheckedHotkey | null; +``` + +Defined in: [app-hotkeys.ts:139](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L139) + +Default hotkey: a chord, a sequence, or `null` for an action without a default. + +*** + +### meta? + +```ts +optional meta?: HotkeyMeta; +``` + +Defined in: [app-hotkeys.ts:141](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L141) + +Display metadata for cheat sheets and settings screens. + +*** + +### options? + +```ts +optional options?: AppHotkeyOptions; +``` + +Defined in: [app-hotkeys.ts:153](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L153) + +Options that describe the hotkey itself. Chord defaults accept +`requireReset`; sequence defaults accept `timeout`. + +*** + +### scope? + +```ts +optional scope?: string; +``` + +Defined in: [app-hotkeys.ts:148](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L148) + +Scope this hotkey fires in, such as `'editor'`. Overrides the scope of the +provider it registers under. App hotkeys in different scopes may share a +hotkey; one in the `'global'` scope conflicts with any app hotkey that +shares its hotkey. diff --git a/docs/reference/interfaces/AppHotkeyListItem.md b/docs/reference/interfaces/AppHotkeyListItem.md index e79a76a80..cbe30ea0c 100644 --- a/docs/reference/interfaces/AppHotkeyListItem.md +++ b/docs/reference/interfaces/AppHotkeyListItem.md @@ -5,7 +5,7 @@ title: AppHotkeyListItem -Defined in: [app-hotkeys.ts:401](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L401) +Defined in: [app-hotkeys.ts:531](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L531) One row of an app hotkey cheat sheet. @@ -23,7 +23,7 @@ One row of an app hotkey cheat sheet. appHotkey: T; ``` -Defined in: [app-hotkeys.ts:402](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L402) +Defined in: [app-hotkeys.ts:532](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L532) *** @@ -33,7 +33,7 @@ Defined in: [app-hotkeys.ts:402](https://github.com/TanStack/hotkeys/blob/main/p isCustom: boolean; ``` -Defined in: [app-hotkeys.ts:405](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L405) +Defined in: [app-hotkeys.ts:535](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L535) Whether the effective hotkey differs from the declared default. @@ -45,7 +45,7 @@ Whether the effective hotkey differs from the declared default. registrations: HotkeyRegistrationView[]; ``` -Defined in: [app-hotkeys.ts:407](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L407) +Defined in: [app-hotkeys.ts:537](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L537) Live registrations of this app hotkey (for example, one per list row). @@ -57,4 +57,4 @@ Live registrations of this app hotkey (for example, one per list row). status: AppHotkeyStatus; ``` -Defined in: [app-hotkeys.ts:403](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L403) +Defined in: [app-hotkeys.ts:533](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L533) diff --git a/docs/reference/interfaces/AppHotkeysState.md b/docs/reference/interfaces/AppHotkeysState.md index 6675f0e2e..40893a333 100644 --- a/docs/reference/interfaces/AppHotkeysState.md +++ b/docs/reference/interfaces/AppHotkeysState.md @@ -5,7 +5,7 @@ title: AppHotkeysState -Defined in: [app-hotkeys.ts:411](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L411) +Defined in: [app-hotkeys.ts:541](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L541) State of an `AppHotkeysStore`. @@ -23,7 +23,7 @@ State of an `AppHotkeysStore`. appHotkeys: T; ``` -Defined in: [app-hotkeys.ts:413](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L413) +Defined in: [app-hotkeys.ts:543](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L543) Effective app hotkeys: declarations with custom hotkeys applied. @@ -35,6 +35,6 @@ Effective app hotkeys: declarations with custom hotkeys applied. customHotkeys: CustomHotkeys; ``` -Defined in: [app-hotkeys.ts:415](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L415) +Defined in: [app-hotkeys.ts:545](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L545) The user's hotkeys that differ from the defaults. diff --git a/docs/reference/interfaces/AppHotkeysStoreOptions.md b/docs/reference/interfaces/AppHotkeysStoreOptions.md index d4bd8ed7d..0b965939f 100644 --- a/docs/reference/interfaces/AppHotkeysStoreOptions.md +++ b/docs/reference/interfaces/AppHotkeysStoreOptions.md @@ -5,7 +5,7 @@ title: AppHotkeysStoreOptions -Defined in: [app-hotkeys.ts:452](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L452) +Defined in: [app-hotkeys.ts:582](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L582) Options for `AppHotkeysStore`. @@ -23,7 +23,7 @@ Options for `AppHotkeysStore`. optional customHotkeys?: CustomHotkeys | null; ``` -Defined in: [app-hotkeys.ts:460](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L460) +Defined in: [app-hotkeys.ts:590](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L590) The user's saved custom hotkeys. Unknown ids and invalid entries are ignored. Passing a different value to `setOptions` later, such as data @@ -39,7 +39,7 @@ clears them. optional onCustomHotkeysChange?: (customHotkeys) => void; ``` -Defined in: [app-hotkeys.ts:462](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L462) +Defined in: [app-hotkeys.ts:592](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L592) Called with the custom hotkeys after every change, ready to save. @@ -61,6 +61,6 @@ Called with the custom hotkeys after every change, ready to save. optional platform?: HotkeyPlatform; ``` -Defined in: [app-hotkeys.ts:464](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L464) +Defined in: [app-hotkeys.ts:594](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L594) Platform used to compare hotkeys. Defaults to detection. diff --git a/docs/reference/interfaces/CustomHotkeyActions.md b/docs/reference/interfaces/CustomHotkeyActions.md index a99c2ebf4..e694b3c87 100644 --- a/docs/reference/interfaces/CustomHotkeyActions.md +++ b/docs/reference/interfaces/CustomHotkeyActions.md @@ -5,7 +5,7 @@ title: CustomHotkeyActions -Defined in: [app-hotkeys.ts:424](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L424) +Defined in: [app-hotkeys.ts:554](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L554) Actions that change the user's custom hotkeys, as adapters return them. @@ -20,7 +20,7 @@ findConflicts: (id, hotkey, recordedWith?) => AppHotkey[]; ``` -Defined in: [app-hotkeys.ts:444](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L444) +Defined in: [app-hotkeys.ts:574](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L574) Other app hotkeys that would collide if `id` used `hotkey`. Pass the recorder's `context` for a recorded hotkey: it has the key press, which @@ -55,7 +55,7 @@ also finds a hotkey written differently that the same press fires. resetCustomHotkey: (id) => void; ``` -Defined in: [app-hotkeys.ts:436](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L436) +Defined in: [app-hotkeys.ts:566](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L566) Restores the default hotkey for an app hotkey. @@ -77,7 +77,7 @@ Restores the default hotkey for an app hotkey. resetCustomHotkeys: () => void; ``` -Defined in: [app-hotkeys.ts:438](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L438) +Defined in: [app-hotkeys.ts:568](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L568) Restores every default hotkey. @@ -96,7 +96,7 @@ setCustomHotkey: (id, hotkey, recordedWith?) => AppHotkey[]; ``` -Defined in: [app-hotkeys.ts:430](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L430) +Defined in: [app-hotkeys.ts:560](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L560) Sets the user's hotkey for an app hotkey. `null` unbinds it. Returns conflicting app hotkeys; when any exist, nothing changes. Pass diff --git a/docs/reference/interfaces/RecordedKeyPresses.md b/docs/reference/interfaces/RecordedKeyPresses.md index 8752636c5..01d613f4e 100644 --- a/docs/reference/interfaces/RecordedKeyPresses.md +++ b/docs/reference/interfaces/RecordedKeyPresses.md @@ -5,7 +5,7 @@ title: RecordedKeyPresses -Defined in: [app-hotkeys.ts:363](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L363) +Defined in: [app-hotkeys.ts:493](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L493) The key presses that recorded a hotkey. A recorder passes them to `validate` and `onRecord` as its context, which can be passed on as is. @@ -18,7 +18,7 @@ and `onRecord` as its context, which can be passed on as is. optional event?: KeyboardEvent; ``` -Defined in: [app-hotkeys.ts:365](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L365) +Defined in: [app-hotkeys.ts:495](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L495) The key press that recorded a chord. @@ -30,6 +30,6 @@ The key press that recorded a chord. optional events?: readonly KeyboardEvent[]; ``` -Defined in: [app-hotkeys.ts:367](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L367) +Defined in: [app-hotkeys.ts:497](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L497) The key press that recorded each step of a sequence. diff --git a/docs/reference/type-aliases/AppHotkeyDefaultKind.md b/docs/reference/type-aliases/AppHotkeyDefaultKind.md index 0ffbaeeb8..8d3128f38 100644 --- a/docs/reference/type-aliases/AppHotkeyDefaultKind.md +++ b/docs/reference/type-aliases/AppHotkeyDefaultKind.md @@ -9,7 +9,7 @@ title: AppHotkeyDefaultKind type AppHotkeyDefaultKind = THotkey extends null ? null : THotkey extends readonly [unknown] ? HotkeyChord : THotkey extends ReadonlyArray ? HotkeySequence : HotkeyChord; ``` -Defined in: [app-hotkeys.ts:141](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L141) +Defined in: [app-hotkeys.ts:259](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L259) The kind of a declared default hotkey; a one-step sequence is a chord. diff --git a/docs/reference/type-aliases/AppHotkeyId.md b/docs/reference/type-aliases/AppHotkeyId.md index 8048172f5..47dcf572f 100644 --- a/docs/reference/type-aliases/AppHotkeyId.md +++ b/docs/reference/type-aliases/AppHotkeyId.md @@ -9,6 +9,6 @@ title: AppHotkeyId type AppHotkeyId = keyof RegisteredAppHotkeys & string; ``` -Defined in: [app-hotkeys.ts:181](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L181) +Defined in: [app-hotkeys.ts:304](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L304) Ids of the registered app hotkeys. diff --git a/docs/reference/type-aliases/AppHotkeyStatus.md b/docs/reference/type-aliases/AppHotkeyStatus.md index 40823da65..3b8a5032f 100644 --- a/docs/reference/type-aliases/AppHotkeyStatus.md +++ b/docs/reference/type-aliases/AppHotkeyStatus.md @@ -12,7 +12,7 @@ type AppHotkeyStatus = | "unbound"; ``` -Defined in: [app-hotkeys.ts:398](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L398) +Defined in: [app-hotkeys.ts:528](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L528) Status of an app hotkey in the running app. - `'active'`: at least one enabled registration diff --git a/docs/reference/type-aliases/CustomHotkeys.md b/docs/reference/type-aliases/CustomHotkeys.md index 750a711e8..91a85e248 100644 --- a/docs/reference/type-aliases/CustomHotkeys.md +++ b/docs/reference/type-aliases/CustomHotkeys.md @@ -9,7 +9,7 @@ title: CustomHotkeys type CustomHotkeys = { -readonly [K in keyof T]?: Hotkey | null }; ``` -Defined in: [app-hotkeys.ts:187](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L187) +Defined in: [app-hotkeys.ts:310](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L310) The user's hotkeys that differ from the declared defaults, keyed by app hotkey id. This is the shape to save. `null` means the user unbound it. diff --git a/docs/reference/type-aliases/DefinedAppHotkeys.md b/docs/reference/type-aliases/DefinedAppHotkeys.md index 49952206f..94cde43e3 100644 --- a/docs/reference/type-aliases/DefinedAppHotkeys.md +++ b/docs/reference/type-aliases/DefinedAppHotkeys.md @@ -9,7 +9,7 @@ title: DefinedAppHotkeys type DefinedAppHotkeys = { readonly [K in keyof T & string]: AppHotkey> }; ``` -Defined in: [app-hotkeys.ts:156](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L156) +Defined in: [app-hotkeys.ts:274](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L274) The app hotkeys returned by `defineAppHotkeys` for a declaration object. An entry that is already an app hotkey, spread in from another @@ -21,4 +21,4 @@ the user's custom hotkey, which would become the new default. ### T -`T` *extends* `Record`\<`string`, [`AppHotkeyInput`](../interfaces/AppHotkeyInput.md)\> +`T` *extends* `Record`\<`string`, [`AppHotkeyDeclaration`](../interfaces/AppHotkeyDeclaration.md)\> diff --git a/docs/reference/type-aliases/RegisteredAppHotkeyListItem.md b/docs/reference/type-aliases/RegisteredAppHotkeyListItem.md index 8fa18ba3c..d4c1e8b4e 100644 --- a/docs/reference/type-aliases/RegisteredAppHotkeyListItem.md +++ b/docs/reference/type-aliases/RegisteredAppHotkeyListItem.md @@ -9,6 +9,6 @@ title: RegisteredAppHotkeyListItem type RegisteredAppHotkeyListItem = AppHotkeyListItem; ``` -Defined in: [app-hotkeys.ts:419](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L419) +Defined in: [app-hotkeys.ts:549](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L549) A cheat sheet row for one of the registered app hotkeys. diff --git a/docs/reference/type-aliases/RegisteredAppHotkeys.md b/docs/reference/type-aliases/RegisteredAppHotkeys.md index 1459a971a..ff57a195e 100644 --- a/docs/reference/type-aliases/RegisteredAppHotkeys.md +++ b/docs/reference/type-aliases/RegisteredAppHotkeys.md @@ -9,6 +9,6 @@ title: RegisteredAppHotkeys type RegisteredAppHotkeys = Register extends object ? T : AppHotkeys; ``` -Defined in: [app-hotkeys.ts:174](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L174) +Defined in: [app-hotkeys.ts:297](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/app-hotkeys.ts#L297) The app hotkeys type from `Register`, or a generic map when none is registered. diff --git a/packages/hotkeys/src/app-hotkeys.ts b/packages/hotkeys/src/app-hotkeys.ts index 649531da6..8e4aba79a 100644 --- a/packages/hotkeys/src/app-hotkeys.ts +++ b/packages/hotkeys/src/app-hotkeys.ts @@ -99,42 +99,160 @@ export interface AppHotkey< /** A map of app hotkeys keyed by id. */ export type AppHotkeys = Readonly> -type AllowedOptions = THotkey extends HotkeySequence - ? AppHotkeySequenceOptions - : THotkey extends null - ? AppHotkeyOptions - : AppHotkeyChordOptions +// An array is a sequence even when TypeScript widens it to `string[]`, as +// for an array literal in a conditional expression. +type AllowedOptions = + THotkey extends ReadonlyArray + ? AppHotkeySequenceOptions + : THotkey extends null + ? AppHotkeyOptions + : AppHotkeyChordOptions type StrictOptions = TOptions extends object ? { [P in Exclude]: never } & TAllowed : TAllowed +declare const uncheckedHotkey: unique symbol + +/** + * A marker in `AppHotkeyDeclaration['hotkey']` that no hotkey value has. A + * hotkey type that includes it is the constraint itself, seen while the + * declarations are still being inferred, not a value someone wrote. + */ +interface UncheckedHotkey { + readonly [uncheckedHotkey]: true +} + /** - * Rejects options that do not apply to each declaration's default kind. + * The shape of a declaration before `defineAppHotkeys` checks its hotkey and + * options. `DefinedAppHotkeys` takes a map of these. * - * Each entry holds only `options`. `defineAppHotkeys` intersects this with - * the declarations, and repeating a declaration's `hotkey` here makes - * TypeScript 5.7 and later intersect two copies of the hotkey unions, which - * takes seconds and gigabytes for a few dozen entries. + * It names no hotkey type on purpose. While TypeScript infers the + * declarations, it checks every literal in the call against contextual types + * built from this shape, and each check walks any union it finds. With the + * chord union (thousands of members) here, each keystroke in a large + * declaration took seconds in editors. `ValidatedAppHotkeyInputs` checks each + * hotkey once the declarations are inferred. */ -type ValidatedAppHotkeyInputs = { - [K in keyof T]: T[K] extends AppHotkey - ? [AppHotkeyOptions] extends [NonNullable] +export interface AppHotkeyDeclaration { + /** Default hotkey: a chord, a sequence, or `null` for an action without a default. */ + hotkey: string | ReadonlyArray | UncheckedHotkey | null + /** Display metadata for cheat sheets and settings screens. */ + meta?: HotkeyMeta + /** + * Scope this hotkey fires in, such as `'editor'`. Overrides the scope of the + * provider it registers under. App hotkeys in different scopes may share a + * hotkey; one in the `'global'` scope conflicts with any app hotkey that + * shares its hotkey. + */ + scope?: string + /** + * Options that describe the hotkey itself. Chord defaults accept + * `requireReset`; sequence defaults accept `timeout`. + */ + options?: AppHotkeyOptions +} + +/** + * The property docs of a declaration, for hover in editors. Each property is + * `unknown`, so intersecting it leaves the declaration's types unchanged. + */ +interface AppHotkeyDeclarationDocs { + /** Default hotkey: a chord, a sequence, or `null` for an action without a default. */ + hotkey?: unknown + /** Display metadata for cheat sheets and settings screens. */ + meta?: unknown + /** + * Scope this hotkey fires in, such as `'editor'`. Overrides the scope of the + * provider it registers under. App hotkeys in different scopes may share a + * hotkey; one in the `'global'` scope conflicts with any app hotkey that + * shares its hotkey. + */ + scope?: unknown + /** + * Options that describe the hotkey itself. Chord defaults accept + * `requireReset`; sequence defaults accept `timeout`. + */ + options?: unknown +} + +/** + * Whether a declared hotkey is valid. A string is checked against the chord + * union and a sequence step by step, which avoids relating each sequence to + * every chord. The unresolved constraint, seen while the declarations are + * still being inferred, counts as valid so that contextual types stay free + * of the hotkey unions. + */ +type IsValidHotkey = [UncheckedHotkey] extends [THotkey] + ? true + : [THotkey] extends [null] + ? true + : [THotkey] extends [string] + ? [THotkey] extends [HotkeyChord] + ? true + : false + : [THotkey] extends [ReadonlyArray] + ? [TStep] extends [HotkeyChord] + ? true + : false + : [THotkey] extends [Hotkey | null] + ? true + : false + +/** + * The kind of a spread-in app hotkey's `hotkey`: its declared kind while it + * is the unchanged `Hotkey | null`, or the kind of a replacement. + */ +type SpreadInKind = [THotkey] extends [null] + ? null + : [Hotkey | null] extends [THotkey] + ? TDefault + : AppHotkeyDefaultKind + +/** + * Rejects options that do not apply to a declaration's default kind. A + * spread-in app hotkey keeps its declared kind unless the declaration + * replaces its `hotkey`, and its unchanged options were checked by its own + * `defineAppHotkeys` call. + */ +type ValidatedOptions = + TInput extends AppHotkey + ? [AppHotkeyOptions] extends [NonNullable] ? unknown : { options?: StrictOptions< - T[K]['options'], - AllowedOptions> - > - } - : T[K] extends { hotkey: infer THotkey } - ? { - options?: StrictOptions< - T[K] extends { options: infer TOptions } ? TOptions : {}, - AllowedOptions + TInput['options'], + AllowedOptions> > } - : never + : { + options?: StrictOptions< + TInput extends { options: infer TOptions } ? TOptions : {}, + AllowedOptions + > + } + +/** + * Checks each declaration once `T` is inferred. Options must match the + * default's kind. An invalid hotkey string or step is reported against + * `Hotkey | null`, which gives TypeScript's "Did you mean" suggestion. Each + * checked entry is intersected with `AppHotkeyDeclarationDocs` so editors + * show its property docs on hover. + * + * The valid branch repeats the declaration (`T[K]`) rather than its + * `hotkey` type. Repeating the hotkey type makes TypeScript 5.7 and later + * intersect two copies of the hotkey unions, which takes seconds and + * gigabytes for a few dozen entries. + */ +type ValidatedAppHotkeyInputs = { + [K in keyof T]: T[K] extends { hotkey: infer THotkey } + ? IsValidHotkey extends true + ? T[K] & AppHotkeyDeclarationDocs & ValidatedOptions + : Omit & { + hotkey: Hotkey | null + } & AppHotkeyDeclarationDocs & + ValidatedOptions + : never } /** The kind of a declared default hotkey; a one-step sequence is a chord. */ @@ -153,20 +271,25 @@ export type AppHotkeyDefaultKind = THotkey extends null * of `defineAppHotkeys`, not app hotkeys read from a store: their `hotkey` is * the user's custom hotkey, which would become the new default. */ -export type DefinedAppHotkeys> = { - readonly [K in keyof T & string]: AppHotkey> -} +export type DefinedAppHotkeys> = + { + readonly [K in keyof T & string]: AppHotkey> + } /** * The default kind of one declaration. A spread-in app hotkey keeps its own - * kind unless the declaration replaces its `hotkey`. + * kind unless the declaration replaces its `hotkey`. The hotkey type is read + * with `infer`: inside the `AppHotkey` branch, `TInput['hotkey']` would be + * intersected with `Hotkey | null`, and with a generic id, such as + * `typeof appHotkeys[TId]`, that intersection is too large to represent. */ -type DeclaredDefaultKind = - TInput extends AppHotkey - ? [Hotkey | null] extends [TInput['hotkey']] - ? TDefault - : AppHotkeyDefaultKind - : AppHotkeyDefaultKind +type DeclaredDefaultKind = TInput extends { + hotkey: infer THotkey +} + ? TInput extends AppHotkey + ? SpreadInKind + : AppHotkeyDefaultKind + : never export type { Register } from './register' @@ -193,6 +316,11 @@ export type CustomHotkeys = { * sheets and settings screens can list hotkeys whose components have not * mounted. Pass the result to `HotkeysProvider` as `appHotkeys`. * + * Spread the results of other `defineAppHotkeys` calls to combine + * declarations from several files. To pick declarations at runtime, call + * `defineAppHotkeys` in each branch: a union of declaration objects doesn't + * type-check. + * * @example * ```ts * export const appHotkeys = defineAppHotkeys({ @@ -203,11 +331,13 @@ export type CustomHotkeys = { * ``` */ export function defineAppHotkeys< - const T extends Record, ->(definitions: T & ValidatedAppHotkeyInputs): DefinedAppHotkeys { + const T extends Record, +>(definitions: ValidatedAppHotkeyInputs): DefinedAppHotkeys { installAppHotkeysStore() const result: Record = {} - for (const [id, input] of Object.entries(definitions as T)) { + for (const [id, input] of Object.entries( + definitions as Record, + )) { const hotkey = input.hotkey === null ? null : simplifyHotkey(input.hotkey) result[id] = { '~appHotkey': true, diff --git a/packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts b/packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts new file mode 100644 index 000000000..71e7ed0b1 --- /dev/null +++ b/packages/hotkeys/tests/app-hotkeys-editor-latency.test.ts @@ -0,0 +1,135 @@ +import path from 'node:path' +import ts from 'typescript' +import { describe, expect, it } from 'vitest' + +// Editors re-check a file on every keystroke, and `tsc` doesn't show that +// cost. `defineAppHotkeys` once took over a second per keystroke for 300 +// declarations, about eight times the same declarations checked with +// `as const satisfies`, because each literal in the call was checked against +// a contextual type that held the chord union. This test types a hotkey +// string through the language service and compares the two. It compares the +// best of several interleaved runs as a ratio, so a slower machine or a pause +// in one run is unlikely to fail it. + +const testsDir = import.meta.dirname +const srcIndex = path.join(testsDir, '../src/index') + +function declarations(count: number): string { + const keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + const lines = [` 'target': { hotkey: 'Mod+K', meta: { name: 'Target' } },`] + for (let i = 1; i < count; i++) { + const key = keys[i % keys.length] + lines.push( + i % 2 === 0 + ? ` 'sequence.${i}': { hotkey: ['G', '${key}'], meta: { name: 'Sequence ${i}' }, options: { timeout: 800 } },` + : ` 'chord.${i}': { hotkey: 'Mod+Alt+${key}', meta: { name: 'Chord ${i}' }, options: { requireReset: true } },`, + ) + } + return `{\n${lines.join('\n')}\n}` +} + +const files = { + define: [ + `import { defineAppHotkeys } from ${JSON.stringify(srcIndex)}`, + `export const appHotkeys = defineAppHotkeys(${declarations(300)})`, + ].join('\n'), + satisfies: [ + `import type { AppHotkeyInput } from ${JSON.stringify(srcIndex)}`, + `export const appHotkeys = ${declarations(300)} as const satisfies Record`, + ].join('\n'), +} + +function createService() { + const options: ts.CompilerOptions = { + target: ts.ScriptTarget.ES2022, + module: ts.ModuleKind.ESNext, + moduleResolution: ts.ModuleResolutionKind.Bundler, + lib: ['lib.es2022.d.ts', 'lib.dom.d.ts'], + strict: true, + noEmit: true, + skipLibCheck: true, + types: [], + } + const texts = new Map() + const versions = new Map() + for (const [name, text] of Object.entries(files)) { + texts.set(path.join(testsDir, `__latency-${name}.ts`), text) + } + const service = ts.createLanguageService({ + getScriptFileNames: () => [...texts.keys()], + getScriptVersion: (file) => String(versions.get(file) ?? 0), + getScriptSnapshot: (file) => { + const text = texts.get(file) ?? ts.sys.readFile(file) + return text === undefined ? undefined : ts.ScriptSnapshot.fromString(text) + }, + getCurrentDirectory: () => testsDir, + getCompilationSettings: () => options, + getDefaultLibFileName: (o) => ts.getDefaultLibFilePath(o), + fileExists: (file) => texts.has(file) || ts.sys.fileExists(file), + readFile: (file) => texts.get(file) ?? ts.sys.readFile(file), + readDirectory: ts.sys.readDirectory, + directoryExists: ts.sys.directoryExists, + getDirectories: ts.sys.getDirectories, + }) + + /** + * Retypes `'Mod+K'`. Returns the slowest keystroke in milliseconds, and + * the errors and completions at the partial `'Mod+'`, which show the call + * was checked. + */ + function typeHotkey(name: keyof typeof files) { + const file = path.join(testsDir, `__latency-${name}.ts`) + const original = files[name] + const start = original.indexOf(`'Mod+K'`) + 1 + service.getSemanticDiagnostics(file) + let slowest = 0 + let errors = 0 + let completions = 0 + for (const step of ['Mod+', 'Mod+S', 'Mod+Sh', 'Mod+Shift+K']) { + texts.set( + file, + original.slice(0, start) + step + original.slice(start + 5), + ) + versions.set(file, (versions.get(file) ?? 0) + 1) + const begin = performance.now() + const diagnostics = service.getSemanticDiagnostics(file) + const list = service.getCompletionsAtPosition( + file, + start + step.length, + {}, + ) + slowest = Math.max(slowest, performance.now() - begin) + if (step === 'Mod+') { + errors = diagnostics.length + completions = list?.entries.length ?? 0 + } + } + return { slowest, errors, completions } + } + + return { typeHotkey } +} + +describe('defineAppHotkeys editor latency', () => { + it('re-checks 300 declarations about as fast as `satisfies`', () => { + const { typeHotkey } = createService() + // Warm up the checker caches that both files share. + typeHotkey('satisfies') + let satisfies = Infinity + let define = Infinity + let checked = { errors: 0, completions: 0 } + for (let run = 0; run < 2; run++) { + satisfies = Math.min(satisfies, typeHotkey('satisfies').slowest) + const result = typeHotkey('define') + define = Math.min(define, result.slowest) + checked = result + } + // The partial hotkey is an error and the chords are offered, so the + // language service checked the call rather than an `any`. + expect(checked.errors).toBe(1) + expect(checked.completions).toBeGreaterThan(1000) + // About 0.8 with this fix and 8.4 without it. + expect(define / satisfies).toBeLessThan(4) + // Shared CI runners check this many times slower than a laptop. + }, 180_000) +}) diff --git a/packages/hotkeys/tests/app-hotkeys-factory.test.ts b/packages/hotkeys/tests/app-hotkeys-factory.test.ts index 94e2d0176..f5017bbb4 100644 --- a/packages/hotkeys/tests/app-hotkeys-factory.test.ts +++ b/packages/hotkeys/tests/app-hotkeys-factory.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it, vi } from 'vitest' +import type { AppHotkeyInput } from '../src' const message = '[hotkeys] defineAppHotkeys did not run in this bundle. Import the app hotkeys in the module that renders the provider. With React Server Components, render AppHotkeysProvider instead of HotkeysProvider.' @@ -11,10 +12,10 @@ async function loadFactory() { } describe('createAppHotkeysStore without defineAppHotkeys in the bundle', () => { - it.each([ + it.each<[string, Record]>([ ['one hotkey', { 'doc.save': { hotkey: 'Mod+S' } }], ['no hotkeys', {}], - ] as const)( + ])( 'names AppHotkeysProvider for declarations with %s that crossed a server boundary', async (_, definitions) => { const { defineAppHotkeys } = await import('../src/app-hotkeys') diff --git a/packages/hotkeys/tests/app-hotkeys-type-performance.test.ts b/packages/hotkeys/tests/app-hotkeys-type-performance.test.ts index 9516096f4..1f6c39714 100644 --- a/packages/hotkeys/tests/app-hotkeys-type-performance.test.ts +++ b/packages/hotkeys/tests/app-hotkeys-type-performance.test.ts @@ -1,5 +1,6 @@ import { describe, expect, expectTypeOf, it } from 'vitest' import { defineAppHotkeys } from '../src/index' +import type { AdapterAppHotkeyOptions } from '../src/adapter' import type { AppHotkey, HotkeyChord, HotkeySequence } from '../src/index' // The type check of this file is the test. TypeScript 5.7 and later took @@ -336,3 +337,24 @@ describe('defineAppHotkeys with many spread-in entries', () => { >() }) }) + +describe('a generic id over spread-in app hotkeys', () => { + // A component that takes any app hotkey id, such as a shortcut button, + // looks up `typeof appHotkeys[TId]`. With spread-in entries, TypeScript + // reported that lookup as a union too complex to represent. + it('resolves the options of any id', () => { + const combined = defineAppHotkeys({ + ...appHotkeys, + 'help.open': { hotkey: 'Shift+?' }, + }) + function optionsFor( + _id: TId, + options?: AdapterAppHotkeyOptions<(typeof combined)[TId], EventTarget>, + ) { + return options + } + expect(optionsFor('sequence.49', { timeout: 500 })).toEqual({ + timeout: 500, + }) + }) +}) diff --git a/packages/hotkeys/tests/app-hotkeys.test.ts b/packages/hotkeys/tests/app-hotkeys.test.ts index 609ce0f66..c121aa528 100644 --- a/packages/hotkeys/tests/app-hotkeys.test.ts +++ b/packages/hotkeys/tests/app-hotkeys.test.ts @@ -151,6 +151,67 @@ describe('defineAppHotkeys', () => { }) }) + it('types conditional and nullable hotkeys like the declared values', () => { + const flag = Math.random() > 0.5 + const original = defineAppHotkeys({ x: { hotkey: 'G' } }) + const result = defineAppHotkeys({ + mixed: { hotkey: flag ? (['G'] as const) : (['G', 'G'] as const) }, + nullable: { ...original.x, hotkey: flag ? ('G' as const) : null }, + }) + expectTypeOf(result.mixed).toEqualTypeOf< + AppHotkey<'mixed', HotkeyChord | HotkeySequence> + >() + expectTypeOf(result.nullable).toEqualTypeOf< + AppHotkey<'nullable', HotkeyChord | null> + >() + defineAppHotkeys({ + // @ts-expect-error not a hotkey + y: { hotkey: {} as {} | null }, + }) + const unchecked = 'Mod+S' as string | ReadonlyArray | null + defineAppHotkeys({ + // @ts-expect-error may not be a hotkey + w: { hotkey: unchecked }, + }) + const maybeSequence = ['G', 'S'] as HotkeySequence | null + const replaced = defineAppHotkeys({ + v: { + ...original.x, + hotkey: maybeSequence, + options: { timeout: 500 }, + }, + }) + expectTypeOf(replaced.v).toEqualTypeOf< + AppHotkey<'v', HotkeySequence | null> + >() + defineAppHotkeys({ + // @ts-expect-error not a hotkey + z: { hotkey: 1 }, + }) + const maybe = Math.random() > 0.5 ? null : undefined + defineAppHotkeys({ + conditional: { + hotkey: flag ? ['G', 'H'] : ['G', 'J'], + options: { timeout: 500 }, + }, + fallback: { hotkey: maybe ?? ['G', 'H'], options: { timeout: 500 } }, + }) + defineAppHotkeys({ + conditional: { + hotkey: flag ? ['G', 'H'] : ['G', 'J'], + // @ts-expect-error requireReset applies only to chords + options: { requireReset: true }, + }, + }) + defineAppHotkeys({ + fallback: { + hotkey: maybe ?? ['G', 'H'], + // @ts-expect-error requireReset applies only to chords + options: { requireReset: true }, + }, + }) + }) + it('checks a spread-in app hotkey whose hotkey or options change', () => { const changed = defineAppHotkeys({ sequence: { ...appHotkeys['doc.save'], hotkey: ['G', 'S'] },