Resolve relative image paths against the app's public directory - #56
Draft
simonhamp wants to merge 2 commits into
Draft
Resolve relative image paths against the app's public directory#56simonhamp wants to merge 2 commits into
simonhamp wants to merge 2 commits into
Conversation
`src` implies a URL to anyone coming from the web, but the renderers wanted a real path on disk. A relative path now means "an asset in `public/`" — for `<native:image>` and for the list-item avatar and image slots alike. A leading slash deliberately stays a device filesystem path, since that's how camera captures and gallery picks arrive. Local files on iOS now go through an NSCache keyed on path, mtime and size, so a list of local thumbnails doesn't re-read and re-decode per row. Android needs no counterpart — Coil already memory-caches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drops the dev-element scaffolding: the MOBILE_AIR_TOKEN auth step, the VCS repository, and the stability tweaks. The committed composer.json was always clean — all of that was CI-only mutation — so the `^4.0` constraint now resolves 4.2.0 straight from Packagist, and forks build the same way we do. `update` rather than `install`: composer.lock is gitignored, so there is never a lock file to install from. The 8.4 pin stays (8.3 still fails to resolve) but its comment was stale — core declares `php ^8.4` itself now, rather than inheriting it from endroid/qr-code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Why
srcimplies a URL to anyone coming from the web, but the underlying renderers want a real path on disk. So<native:image src="img/logo.png">— the most natural thing to write — silently rendered nothing.Short-circuit it: a relative path means "an asset in
public/", applied consistently to<native:image>and toleadingAvatar/leadingImageon<native:list-item>.What changed
Resolution lives in the renderers, in one shared helper per platform (
NativeUIImageSource.kt/NativeUIImageSource.swift):srchttps://…,data:…,file://…,content://…/var/mobile/…/photo.jpgimg/logo.png,./img/logo.pngpublic/img/logo.pngon deviceA leading slash deliberately stays a device filesystem path, not the public root as it would be on the web. That's how camera captures and gallery picks arrive, and reclaiming it would break them. Documented in the Boost guidelines and in both helpers, since it's the thing a web developer will get wrong.
Two things fixed on the way:
AsyncImage(url:), which can't open any local file — soleadingAvatar="/var/mobile/…/photo.jpg"was silently broken there too, absolute paths included.NSCachekeyed on path + mtime + size, so a list of local thumbnails doesn't re-read and re-decode per row, and overwriting a file in place (re-taking an avatar) doesn't serve a stale image. Android needs no counterpart — Coil already memory-caches by model.CI: off
dev-element, onto PackagistSecond commit, independent of the above. Now that v4 has shipped, the
^4.0constraint incomposer.jsonresolves straight from Packagist, so the workflow drops theMOBILE_AIR_TOKENauth step, the VCS repository and theminimum-stability: devtweaks — the committedcomposer.jsonwas always clean, all of that was CI-only mutation. Forks now build the same way we do.Verified by dry-run: resolves
nativephp/mobile 4.2.0with no token and no VCS repo. The8.4pin stays (8.3 still fails to resolve), but its comment was stale — core declaresphp ^8.4itself now rather than inheriting it fromendroid/qr-code.Blocked on a core release
src/Elements/ListItem.phpcallsNative\Mobile\Edge\ImageSource::forDevice(), which doesn't exist yet. It's the Jump half of this: undernative:jumpPHP runs on the dev machine, sopublic/is only reachable over HTTP, and core rewrites relative paths withasset(). The Jump router already forwards a phone-reachableHostheader, so this needs no new plumbing and — importantly — no changes to the Jump app: it just receives an ordinary URL, which every existing build already renders.Because CI now resolves released versions rather than tracking a branch, this PR stays red until that core change merges to
mainand is tagged, after which the constraint here needs bumping from^4.0to that release.Testing
xcrun swiftc -parse, the check CI runs.PHPBridgeusage inWebviewRenderer.kt.🤖 Generated with Claude Code