refactor(timing): extract after()/TimerHandle into SwiflowTiming with a host ManualTimers arm#255
Merged
Merged
Conversation
… a host ManualTimers arm SwiflowUI's only SwiflowDOM use was Toast's auto-dismiss timer, which pulled the whole renderer into the UI library's dependency closure and — gated on canImport(JavaScriptKit), true on host — trapped at JSObject.global.setTimeout the moment a host harness mounted a ToastView. The new leaf target splits on arch(wasm32): the wasm arm keeps the JSOneshotClosure implementation verbatim, the host arm queues into ManualTimers for tests to advance. SwiflowDOM re-exports the module, so app code importing SwiflowDOM is source-compatible. ToastView's dismiss countdown and WCAG 2.2.1 hover/focus pause-resume are now covered by host tests (ToastTimerTests) instead of being demo-verified. Whole-package swift test: 1901 tests green. SwiflowUIDemo + GridBoard wasm builds verified locally (CI skips examples). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📦 Bundle size
✅ Within budget (≤5% growth allowed). Baseline: Swift 6.3, WASM SDK 6.3-RELEASE, measured 2026-06-18. |
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.
Part-1 modularization-audit fix (finding 2).
Problem. SwiflowUI's only use of SwiflowDOM was Toast's auto-dismiss timer — a view library depending on the render backend for a 101-line utility. Worse, the timer was gated on
canImport(JavaScriptKit)(true on host), so a host harness mountingToastViewwalked straight intoJSObject.global.setTimeout!and trapped; auto-dismiss and its WCAG pause were demo-verified only.Change.
SwiflowTimingowningafter()/TimerHandle, split onarch(wasm32)per the repo rule. The wasm arm keeps theJSOneshotClosureimplementation verbatim (same release contract); the host arm queues intoManualTimers— a public, test-driven queue (advance(by:),reset(),pendingCount) mirroring theManualClockpattern.SwiflowDOMre-exports the module (@_exported), so app code that imports SwiflowDOM (e.g. GridBoard) compiles unchanged.SwiflowUInow depends onSwiflowTiminginstead ofSwiflowDOM; Toast's#if canImporttimer gates are gone.ToastTimerTests(serialized suite owning theManualTimersseam): countdown arms on mount and dismisses exactly once; hover pause re-arms the FULL duration on leave (WCAG 2.2.1); focusin/focusout pause; the countdown stays paused while either hold remains.Verification. Whole-package
swift test: 1901 tests, 351 suites, green. SwiflowUIDemo and GridBoard wasm builds pass locally (CI skips examples); GridBoard exercises the re-export path.🤖 Generated with Claude Code