Skip to content

refactor(bundle-size): use free-function helpers for events and timers#541

Open
layershifter wants to merge 4 commits into
microsoft:masterfrom
layershifter:chore/bundle-size-stack-4
Open

refactor(bundle-size): use free-function helpers for events and timers#541
layershifter wants to merge 4 commits into
microsoft:masterfrom
layershifter:chore/bundle-size-stack-4

Conversation

@layershifter
Copy link
Copy Markdown
Member

Summary

Replaces inline boilerplate at every call site with shared free-function helpers in Utils.ts:

  • addListener / removeListener for addEventListener / removeEventListener with options
  • dispatchEvent for el.dispatchEvent(new XEvent(...))
  • setTimer / createTimer / free-function Timer API replacing raw setTimeout / clearTimeout boilerplate

These compress better than open-coded calls because the helper name mangles once and references shrink everywhere.

Stack context

Stacked on top of #540. Net new in this PR: the four helper introductions and their call-site sweeps.

layershifter and others added 4 commits May 11, 2026 11:41
\`patch-package\` postinstall hook applies three changes to
keyborg@2.14.0 covering both the ESM (\`dist/index.js\`) and CJS
(\`dist/index.cjs\`) bundles:

1. \`event.details = details\` — drop the \`@deprecated\` alias of
   \`event.detail\`. Tabster reads \`e.detail\` exclusively (verified
   across src/State/FocusedElement.ts and the rest of the codebase).

2. \`triggerKeys\` / \`dismissKeys\` props + the supporting
   \`shouldDismiss\` / \`scheduleDismiss\` / \`dismissTimer\`
   machinery. Tabster only ever calls \`createKeyborg(getWindow())\`
   with no props.

3. \`canOverrideNativeFocus\` runtime probe. Replaces the
   \`_canOverrideNativeFocus\` flag with the implicit-true assumption
   modern browsers (everything since IE9) already satisfy. The
   conditional \`details.isFocusedProgrammatically\` write becomes
   unconditional — semantically identical when override works.

Bundle deltas (createTabster default-mode):
  keyborg slice: 3.71 → 3.12 kB (-590 B, -16%)
  createTabster:  30.78 → 30.18 kB (-600 B)
  getModalizer:   38.47 → 37.87 kB (-600 B)
  getMover:       44.54 → 43.94 kB (-600 B)
  getCrossOrigin: 89.64 → 89.04 kB (-600 B)
  allExports:     92.09 → 91.50 kB (-590 B)

Tests pass: 3 pre-existing failures, no regressions across default,
uncontrolled, and root-dummy-inputs modes.

Stop-gap until upstream microsoft/keyborg can release the same
trims (the changes belong there, not as a Tabster-side fork).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
tabster
all exports
113.84 kB
30.937 kB
110.109 kB
30.281 kB
-3.731 kB
-656 B
tabster
createTabster (core)
39.761 kB
11.892 kB
38.209 kB
11.635 kB
-1.552 kB
-257 B
tabster
focusable.findAll
0 B
0 B
38.232 kB
11.643 kB
🆕 New entry
tabster
focusable.findLast
0 B
0 B
38.233 kB
11.643 kB
🆕 New entry
tabster
focusable.findNext
0 B
0 B
38.233 kB
11.643 kB
🆕 New entry
tabster
focusable.findPrev
0 B
0 B
38.233 kB
11.643 kB
🆕 New entry
tabster
getCrossOrigin
110.623 kB
30.244 kB
107.015 kB
29.555 kB
-3.608 kB
-689 B
tabster
getDeloser
49.268 kB
14.234 kB
47.566 kB
13.947 kB
-1.702 kB
-287 B
tabster
getGroupper
47 kB
13.593 kB
45.294 kB
13.323 kB
-1.706 kB
-270 B
tabster
getModalizer
49.072 kB
14.378 kB
47.422 kB
14.081 kB
-1.65 kB
-297 B
tabster
getMover
54.653 kB
15.887 kB
52.796 kB
15.563 kB
-1.857 kB
-324 B
tabster
getObservedElement
45.564 kB
13.484 kB
44.024 kB
13.229 kB
-1.54 kB
-255 B
tabster
getOutline
48.867 kB
14.216 kB
46.445 kB
13.834 kB
-2.422 kB
-382 B
tabster
getRestorer
42.518 kB
12.52 kB
40.822 kB
12.255 kB
-1.696 kB
-265 B

🤖 This report was generated against a579ebbd50e37f1565551549fe57bbc9ddafab64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant