Skip to content

feat(paywalls): wire web_view messaging into the paywall (PWENG-98)#3653

Open
alexrepty wants to merge 1 commit into
alexrepty/paywalls-web-view-bridgefrom
alexrepty/paywalls-web-view-messaging
Open

feat(paywalls): wire web_view messaging into the paywall (PWENG-98)#3653
alexrepty wants to merge 1 commit into
alexrepty/paywalls-web-view-bridgefrom
alexrepty/paywalls-web-view-messaging

Conversation

@alexrepty

@alexrepty alexrepty commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

Exposes web_view bidirectional messaging to integrating apps and installs the bridge in the rendered paywall — the final piece that makes the feature usable end to end.

Resolves PWENG-98.

Description

  • Adds the public PaywallOptions.setWebViewMessageHandler(...) opt-in, threaded through PaywallState / OfferingToStateMapper / PaywallViewModel.
  • WebViewComponentView constructs and lifecycle-manages the bridge per rendered web_view (scoped by the component id), refreshing locale / handler across recompositions and tearing it down on release.
  • Adds componentId to the web_view style/factory and regenerates ui/revenuecatui/api.txt for the new public handler API.
  • Tested by PaywallOptionsWebViewHandlerTest.

iOS parity: mirrors purchases-ios (web-view-bridge-wiring) (onPaywallWebViewMessage there).
Stack (merge bottom-up): schema → rendering → CSP → value types → message model → variables provider → JS bridge → wiring.


Note

Medium Risk
Touches WebView JS bridging and a new public callback surface; mistakes could affect message delivery or WebView lifecycle, but purchase/dismiss are not auto-triggered by messages.

Overview
Adds PaywallOptions.setWebViewMessageHandler (public API + api.txt) so apps can observe Paywalls V2 web_view messages and reply via PaywallWebViewController. The handler is threaded through PaywallState.Loaded.Components, OfferingToStateMapper, and PaywallViewModel.

WebViewComponentView now creates a WebViewJavaScriptBridge per rendered web view when the style has a componentId (new field from WebViewComponent.id in StyleFactory), injects the shim on page start, refreshes locale/handler on recomposition, and releases on dispose. Handler-only updateOptions changes refresh in place (handler excluded from hashCode, like the listener) without rebuilding paywall state; workflow pre-warmed steps get the same stamp.

Tests cover builder/equality/hash behavior and view-model/workflow handler refresh.

Reviewed by Cursor Bugbot for commit ee282eb. Bugbot is set up for automated code reviews on this repo. Configure here.

@alexrepty alexrepty changed the base branch from alexrepty/paywalls-web-view-csp to graphite-base/3653 June 25, 2026 15:33
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 44cef80 to 05817c6 Compare June 25, 2026 15:33
@alexrepty alexrepty changed the base branch from graphite-base/3653 to alexrepty/paywalls-web-view-message-model June 25, 2026 15:34
@alexrepty alexrepty changed the title feat(paywalls): add web_view bidirectional messaging feat(paywalls): add web_view bidirectional messaging bridge Jun 25, 2026
@alexrepty alexrepty changed the base branch from alexrepty/paywalls-web-view-message-model to graphite-base/3653 June 25, 2026 15:45
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 05817c6 to 026a97f Compare June 25, 2026 15:45
@alexrepty alexrepty changed the base branch from graphite-base/3653 to alexrepty/paywalls-web-view-bridge June 25, 2026 15:45
@alexrepty alexrepty changed the title feat(paywalls): add web_view bidirectional messaging bridge feat(paywalls): wire web_view messaging into the paywall Jun 25, 2026
@alexrepty alexrepty mentioned this pull request Jun 25, 2026
2 tasks
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 026a97f to e1a5a58 Compare June 26, 2026 10:49
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.54%. Comparing base (28307d9) to head (ee282eb).

Additional details and impacted files
@@                         Coverage Diff                         @@
##           alexrepty/paywalls-web-view-bridge    #3653   +/-   ##
===================================================================
  Coverage                               80.54%   80.54%           
===================================================================
  Files                                     401      401           
  Lines                                   16606    16606           
  Branches                                 2373     2373           
===================================================================
  Hits                                    13376    13376           
  Misses                                   2291     2291           
  Partials                                  939      939           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 1704224 to e63218e Compare June 26, 2026 14:20
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch 2 times, most recently from 4778498 to 8e1dbd2 Compare June 26, 2026 14:26
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from e63218e to aab1540 Compare June 26, 2026 14:26
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 8e1dbd2 to 411faa5 Compare June 26, 2026 14:57
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch 2 times, most recently from 8483042 to 7b32cdc Compare June 29, 2026 09:30
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 411faa5 to 87c761e Compare June 29, 2026 09:30
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 7b32cdc to b712772 Compare June 29, 2026 09:58
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 87c761e to 462969f Compare June 29, 2026 09:58
@alexrepty alexrepty changed the title feat(paywalls): wire web_view messaging into the paywall feat(paywalls): wire web_view messaging into the paywall (PWENG-98) Jun 29, 2026
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 462969f to ec0e9e1 Compare June 29, 2026 12:53
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from b712772 to 9627fbf Compare June 29, 2026 12:53
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from ec0e9e1 to 9a5e9d8 Compare June 29, 2026 13:58
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 9627fbf to 5fcb286 Compare June 29, 2026 13:58
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 9a5e9d8 to b9e2d15 Compare June 29, 2026 14:14
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 5fcb286 to 6b3546c Compare June 29, 2026 14:14
@alexrepty alexrepty marked this pull request as ready for review June 29, 2026 14:43
@alexrepty alexrepty requested a review from a team as a code owner June 29, 2026 14:43
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 6b3546c to b7e4c63 Compare June 29, 2026 15:31
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from b9e2d15 to 7459bad Compare June 29, 2026 15:31
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch from 7459bad to 01a65f3 Compare June 29, 2026 16:09
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from b7e4c63 to 35d1a2c Compare June 30, 2026 07:44
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-messaging branch 2 times, most recently from 5d63768 to 9d63625 Compare June 30, 2026 08:43
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-bridge branch from 35d1a2c to 39fe849 Compare June 30, 2026 08:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9d63625. Configure here.

Adds a bidirectional JS<->native bridge for the Paywalls V2 `web_view` component: a document-start `window.RevenueCatWebView` shim, message parsing/validation (`WebViewMessageParser`, `WebViewMessageType`), the public `PaywallWebViewMessage` / `PaywallWebViewValue` / `PaywallWebViewMessageHandler` / `PaywallWebViewController` surface, and an SDK-managed variables provider (locale, color scheme, custom variables). Apps opt in via `PaywallOptions.setWebViewMessageHandler(...)`, threaded through `PaywallState` / `OfferingToStateMapper`.

Regenerates ui/revenuecatui/api.txt for the new public API.

Recommended labels: pr:feat, pr:RevenueCatUI, feat:Paywalls_V2
@AlvaroBrey AlvaroBrey force-pushed the alexrepty/paywalls-web-view-messaging branch from 9d63625 to ee282eb Compare July 6, 2026 08:12
@AlvaroBrey AlvaroBrey force-pushed the alexrepty/paywalls-web-view-bridge branch from 39fe849 to 28307d9 Compare July 6, 2026 08:12
@AlvaroBrey AlvaroBrey self-assigned this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants