refactor(bundle-size): use free-function helpers for timers#541
Open
layershifter wants to merge 1 commit into
Open
refactor(bundle-size): use free-function helpers for timers#541layershifter wants to merge 1 commit into
layershifter wants to merge 1 commit into
Conversation
📊 Bundle size report🤖 This report was generated against 711667861375e72636f73d33df9c8d8644ae45cd |
This was referenced May 11, 2026
layershifter
force-pushed
the
chore/bundle-size-stack-4
branch
3 times, most recently
from
June 11, 2026 13:37
a844939 to
c86ee2e
Compare
layershifter
force-pushed
the
chore/bundle-size-stack-4
branch
from
June 12, 2026 09:55
c86ee2e to
14a3875
Compare
layershifter
force-pushed
the
chore/bundle-size-stack-4
branch
2 times, most recently
from
June 17, 2026 14:21
33ec628 to
fe69479
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors Tabster’s internal use of window timer APIs to route through new free-function helpers in src/Utils.ts, allowing minification to mangle helper names (and avoid preserving .setTimeout/.clearTimeout property names) while enforcing the pattern via ESLint.
Changes:
- Added
Timerhandle type plussetTimer,clearTimer, andisTimerActivehelpers insrc/Utils.ts. - Converted timer usage across
src/**/*.tsto use the new helpers instead of direct.setTimeout/.clearTimeoutcalls. - Updated
eslint.config.mjsto restrict.setTimeout/.clearTimeoutusage outsidesrc/Utils.ts.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Utils.ts | Introduces Timer and the timer helper functions; updates existing instance-context timer usage. |
| src/Tabster.ts | Migrates core init/cleanup timers to Timer + helpers. |
| src/State/ObservedElement.ts | Converts waiting/condition timers to Timer handles and helper calls. |
| src/State/FocusedElement.ts | Migrates async focus and tabbing timers to helper API. |
| src/Root.ts | Converts focus/blur debounce timer to helper API. |
| src/Outline.ts | Converts outline update scheduling timer to helper API. |
| src/Mover.ts | Migrates mover scheduling/update timers and ignored-input timer to helper API. |
| src/Modalizer.ts | Converts hidden update and restore-focus timers to helper API. |
| src/Groupper.ts | Converts groupper update timer to helper API. |
| src/DummyInput.ts | Migrates dummy-input disposal and observer scheduling timers to helper API. |
| src/Deloser.ts | Converts restore-focus timer to helper API. |
| src/CrossOrigin.ts | Migrates cross-origin transaction, ping, and blur timers to helper API. |
| eslint.config.mjs | Adds no-restricted-syntax rules to prevent raw .setTimeout/.clearTimeout calls in src/**. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+620
to
+622
| export interface Timer { | ||
| id: ReturnType<typeof setTimeout> | undefined; | ||
| } |
Introduces single-character-mangleable wrappers in `Utils.ts` for the
window timer APIs whose property names would otherwise be preserved
verbatim by the minifier:
- `setTimer` / `clearTimer` / `isTimerActive`, operating on an opaque
`Timer = { id }` handle stored on instance fields.
`setTimer(t, window, callback, delay)` lazily creates the `Timer` when
passed `undefined` and returns it, so callers just write
`this._timer = setTimer(this._timer, ...)` — no separate constructor-time
allocation. `Timer.id` is typed as `ReturnType<typeof setTimeout>` so the
id round-trips through `window.setTimeout` / `clearTimeout` without a cast;
`undefined` is the not-pending sentinel.
All `src/**/*.ts` call sites converted; raw `.setTimeout` / `.clearTimeout`
property accesses now eliminated outside `Utils.ts`.
Enforced via two additional `no-restricted-syntax` entries in
`eslint.config.mjs` (next to the existing event-helper rules from microsoft#560)
so the wrappers can't drift back into raw timer calls in future PRs.
Follow-up to microsoft#560 — same pattern applied to timer APIs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
layershifter
force-pushed
the
chore/bundle-size-stack-4
branch
from
June 17, 2026 14:53
0a9db99 to
bb51db4
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
Introduces single-character-mangleable wrappers in
Utils.tsfor the window timer APIs whose property names would otherwise be preserved verbatim by the minifier:setTimer/clearTimer/isTimerActive, operating on an opaqueTimer = { id }handle stored on instance fields.setTimer(t, window, callback, delay)lazily creates theTimerwhen passedundefinedand returns it, so callers just writethis._timer = setTimer(this._timer, …)— no separate constructor-time allocation.Timer.idis typed asReturnType<typeof setTimeout>so the id round-trips throughwindow.setTimeout/clearTimeoutwithout a cast;undefinedis the not-pending sentinel.All
src/**/*.tscall sites converted; raw.setTimeout/.clearTimeoutproperty accesses now eliminated outsideUtils.ts.Enforced via two additional
no-restricted-syntaxentries ineslint.config.mjs(next to the existing event-helper rules from #560) so the wrappers can't drift back into raw timer calls in future PRs.Stack context
Follow-up to #560 — same wrapper pattern applied to timer APIs.