fix: restore macOS transparency and defer CSS errors (3.1.1) - #89
Merged
Conversation
Use WKWebView's public under-page background API instead of probing a private KVC selector that is not exposed as a method. Deliver CSS errors on the next main-queue turn so handlers cannot mutate state during a SwiftUI representable update. Add macOS rendering and callback timing regression tests.
Qualify SwiftUI colors, use an Identifiable sheet item, and give generated CSS examples distinct names so the snippets compile on iOS and macOS. Remove the 18 trailing-whitespace errors introduced in the release changes.
3.1.0 shipped with an opaque background on macOS, so new integrations should not start there.
The public API is spelled the American way throughout — `Color`, `ColorSet`,
`fontColor`, `colorPreference`, `underPageBackgroundColor` — but comments and
documentation had picked up British spellings, so prose and identifiers
disagreed on the same line:
"Invalid hex colour in fontColor or linkColor"
Normalized 17 occurrences of colour/colours/colouring and behaviour across
sources, tests, README, CHANGELOG, docs/ and the sample app README. Only prose,
comments and test names changed; no identifier was touched.
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.
Patch release. Fixes two regressions shipped in 3.1.0.
🐛 macOS backgrounds were no longer transparent
3.1.0 guarded the
drawsBackgroundKVC call withresponds(to:):The premise was wrong.
setValue(_:forKey:)does not need asetDrawsBackground:method — KVC falls back to_setDrawsBackground:and then to the_drawsBackgroundivar. So the guard always took theelsebranch:webViewConfigurationFailedA guard intended to prevent a crash disabled the feature it was guarding.
Replaced with
underPageBackgroundColor, which is public WebKit API available on iOS 15 and macOS 12 — exactly this package's deployment targets. No KVC, no private selectors.🐛
cssGenerationFailedfired during a SwiftUI view updateThe handler was called synchronously from
loadHTMLIfNeeded, which runs insidemakeUIViewandupdateUIView. A handler that mutates state there produces "Modifying state during view update, this will cause undefined behavior" — the exact warning #72 reported and #74 fixed. 3.1.0 reintroduced it.Errors are now delivered on the next main-queue turn via
reportError(_:).🧪 Why 3.1.0 shipped without catching either
The 3.1.0 tests compared generated strings. Neither defect is visible that way.
The new tests check behavior instead:
WKWebViewfound inside a hostedNSHostingView📖 Documentation
Examples that did not compile:
.blue/.cyanwere ambiguous between theColorandNSColor/UIColoroverloads → qualified asColor.bluelet csswas declared twice in one scopefullScreenCover(item:)was bound to aString?, which is notIdentifiable, and is iOS-only → replaced with anIdentifiablewrapper and.sheetAlso removed 18 trailing-whitespace errors, and normalized 17 British spellings (
colour,behaviour) that disagreed with the API on the same line:📦 Release prep
3.1.1, since 3.1.0 is opaque on macOS