Skip to content

feat: Screen Wake Lock API on Page#24324

Open
Artur- wants to merge 2 commits into
mainfrom
feature/wake-lock
Open

feat: Screen Wake Lock API on Page#24324
Artur- wants to merge 2 commits into
mainfrom
feature/wake-lock

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 12, 2026

Add a per-UI WakeLock facade reached through Page#getWakeLock(). It exposes request(), release(), and an active-state Signal, matching the conventions used for PageVisibility and Geolocation:

  • Dedicated facade class under com.vaadin.flow.component.page with a package-private constructor.
  • Client logic lives in flow-client/src/main/frontend/WakeLock.ts and is side-effect-imported from Flow.ts; nothing inlined into Java.
  • State travels back as a vaadin-wake-lock-change CustomEvent on document.body with an ACTIVE / RELEASED detail; the facade listens on the UI element and writes to a private ValueSignal.
  • Client transparently re-acquires the lock on visibilitychange so a single request() covers the lifetime of a view; release() clears the "want lock" flag and drops the current sentinel.
  • Failures (insecure context, unsupported browser, denied) log at DEBUG and leave the active signal in its false state.

Add a per-UI WakeLock facade reached through Page#getWakeLock(). It
exposes request(), release(), and an active-state Signal<Boolean>,
matching the conventions used for PageVisibility and Geolocation:

- Dedicated facade class under com.vaadin.flow.component.page with a
  package-private constructor.
- Client logic lives in flow-client/src/main/frontend/WakeLock.ts and
  is side-effect-imported from Flow.ts; nothing inlined into Java.
- State travels back as a vaadin-wake-lock-change CustomEvent on
  document.body with an ACTIVE / RELEASED detail; the facade listens
  on the UI element and writes to a private ValueSignal.
- Client transparently re-acquires the lock on visibilitychange so a
  single request() covers the lifetime of a view; release() clears
  the "want lock" flag and drops the current sentinel.
- Failures (insecure context, unsupported browser, denied) log at
  DEBUG and leave the active signal in its false state.
Signal.effect(Component, EffectAction) has no (Object, Runnable)
overload, so the original @link couldn't resolve and the strict
javadoc check in CI failed. Switch to the same {@code Signal.effect(...)}
shape used by PageVisibility and Geolocation.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Test Results

 1 407 files  +1   1 407 suites  +1   1h 22m 0s ⏱️ -29s
10 146 tests +7  10 076 ✅ +7  70 💤 ±0  0 ❌ ±0 
10 621 runs  +7  10 542 ✅ +7  79 💤 ±0  0 ❌ ±0 

Results for commit 90006de. ± Comparison against base commit 32183d1.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link
Copy Markdown

*
* @return the wake lock facade, never {@code null}
*/
public WakeLock getWakeLock() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other browser feature APIs have their own static methods instead of being accessed throug Page.
Should we make this consistent?

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

Labels

Projects

Status: 🔎Iteration reviews

Development

Successfully merging this pull request may close these issues.

3 participants