Skip to content

feat(native-ui): locked-down webview element#7

Open
simonhamp wants to merge 5 commits into
mainfrom
feat/webview-element
Open

feat(native-ui): locked-down webview element#7
simonhamp wants to merge 5 commits into
mainfrom
feat/webview-element

Conversation

@simonhamp

Copy link
Copy Markdown
Member

What

Adds a <native:webview> leaf element (self-closing, <x-webview /> in Blade) for embedding web content on both platforms — WKWebView on iOS, android.webkit.WebView on Android.

Security posture

Defaults are paranoid by design; hosts opt back into individual capabilities via Blade attributes:

  • JavaScript off by default (javascript attribute to enable)
  • DOM storage off by default (dom-storage attribute to enable)
  • No JS bridge to the host app
  • No new windows: target=_blank / window.open() silently denied on both platforms
  • Non-persistent data store (iOS) / non-persistent cookies + no cache (Android)
  • No file/content access (Android), no link previews or back/forward swipe (iOS)
  • Mixed content blocked (Android MIXED_CONTENT_NEVER_ALLOW)
  • Media playback requires a user gesture
  • Top-frame navigations restricted to https / http / data / about; external schemes (mailto, tel, intent, …) are dropped rather than dispatched to the system

API

<x-webview src="https://example.com" javascript @navigated="onUrlChange" />
<x-webview :html="$inlineHtml" />
  • src — URL to load (loadable schemes only)
  • html — inline HTML, loaded with a null base URL so it gets an opaque origin and can't make same-origin requests against the host app
  • @navigated — fires once per committed top-frame navigation with the resolved URL (didCommit on iOS, onPageCommitVisible on Android)

Content reloads only when src/html actually change (signature check), so recompositions/re-renders don't reset scroll position or flicker.

Notes

  • Registered as self_closing: true — the renderers intentionally ignore children.
  • applyA11yAttributes() wired in like the other elements.
  • Test suite doesn't currently run against the released nativephp/mobile (pre-existing: main already targets unreleased Edge classes like Native\Mobile\Edge\Element), so this was validated by manifest/class cross-check rather than pest.

🤖 Generated with Claude Code

simonhamp and others added 3 commits July 15, 2026 16:11
Adds a <native:webview> leaf element for embedding web content, with a
paranoid-by-default posture: JS off, no DOM storage, no file access, no
JS bridge to the host, no new windows (target=_blank / window.open
denied), mixed content blocked, non-persistent cookies/data store, and
media playback requiring a user gesture. Hosts opt back into individual
capabilities via `javascript` / `dom-storage` attributes.

Content comes from `src` (https/http/data/about schemes only) or inline
`html` (loaded with a null base URL, so it gets an opaque origin).
Top-frame navigations fire `@navigated` with the resolved URL once
committed; external schemes (mailto, tel, intent, ...) are dropped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Package renamed nativephp/native-ui -> nativephp/mobile-ui and the PHP
namespace Nativephp\NativeUi -> Native\Mobile\UI, matching the repo's
new home and bringing the plugin under the framework's Native\Mobile
namespace root (alongside Native\Mobile\Edge from nativephp/mobile).

Touches every class in src/, the PSR-4 mapping + provider FQCN in
composer.json, element/blade FQCNs and the plugin name in nativephp.json,
tests, docs, and namespace mentions in native-side comments. Platform
identifiers are intentionally unchanged: the Kotlin package
(com.nativephp.plugins.native_ui), Swift NativeUI* renderer names, the
manifest bridge namespace ("NativeUI"), and the native-ui config
key/publish tags.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
simonhamp and others added 2 commits July 15, 2026 17:53
The framework's PluginDiscovery and PluginValidateCommand both require
type "nativephp-plugin" exactly; the old "nativephp-ui-plugin" value
this test asserted would never be discovered.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
refactor(mobile-ui)!: rename package to nativephp/mobile-ui
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