perf: refactor Keyborg classes to closure-based factories#144
Open
layershifter wants to merge 1 commit intomicrosoft:mainfrom
Open
perf: refactor Keyborg classes to closure-based factories#144layershifter wants to merge 1 commit intomicrosoft:mainfrom
layershifter wants to merge 1 commit intomicrosoft:mainfrom
Conversation
📊 Bundle size reportUnchanged fixtures
|
This was referenced Apr 22, 2026
f940584 to
2b875cd
Compare
Replaces class KeyborgCore and class Keyborg with factory functions.
Per-instance state moves from this._x fields (which minifiers cannot
mangle at target: "es2019") to closure locals (which they can). Public
API unchanged: createKeyborg, disposeKeyborg, and the Keyborg type
(now an interface) keep the same shape. WindowWithKeyborg.__keyborg
retains its outer { core, refs } shape.
Bundle-size deltas vs post-PR-1 baseline:
- All exports: -1.693 kB min / -212 B gz
- createKeyborg + disposeKeyborg: -1.693 kB min / -211 B gz
- KEYBORG_FOCUSIN constant: no change
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2b875cd to
ed3d2cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
src/Keyborg.mtsto use factory functions instead of classes. Per-instance state lives in closure variables, which the minifier can mangle; class property names likethis._triggerKeyscannot be mangled.Keyborgbecomes an exported interface (it was already only re-exported as a type fromindex.mts).createKeyborg,disposeKeyborg, and theKeyborgCallbacktype are unchanged.WindowWithKeyborg.__keyborgretains its outer{ core, refs }shape for any external consumer (e.g., Tabster) that reads it. The internalcorehandle shape changes: it is now{ dispose, getNavigating, setNavigating }instead of aKeyborgCoreclass instance with a getter/setter forisNavigatingWithKeyboard.Notes for reviewers
core.isNavigatingWithKeyboardgetter/setter is gone. If any consumer readswindow.__keyborg.core.isNavigatingWithKeyboarddirectly, that is an undocumented leak and would break here — please flag if aware of any such consumer._idvalues assigned to instances no longer interleave with core counters. This only shows up in the dev-mode"Keyborg instance <id> is being disposed incorrectly"console.error string.🤖 Generated with Claude Code