-
Notifications
You must be signed in to change notification settings - Fork 438
Refine PWA launches on iOS #3742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fellyph
wants to merge
13
commits into
trunk
Choose a base branch
from
improving-pwa-website
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
818377a
fixing icon on ios
fellyph 2e01334
updating icons and manifest
fellyph d001c91
updating home screen
fellyph 8280d47
adding pwa test
fellyph 319118c
updating PWA for playgrounf website
fellyph e465403
adding changes from the feedback
fellyph f1f4271
Merge branch 'trunk' into improving-pwa-website
fellyph ce71a53
Fix relative PWA manifest asset paths
fellyph c553ab0
Support website-server path in PWA manifest detection
fellyph f10b8cf
Merge branch 'trunk' into improving-pwa-website
fellyph 666008b
Remove trusted base URL helper from PWA manifests
fellyph 0409772
Merge branch 'trunk' into improving-pwa-website
bgrgicak cb52ffd
Reuse dev server detection for PWA manifests
fellyph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,53 @@ | ||
| { | ||
| "id": "/", | ||
| "theme_color": "#ffffff", | ||
| "background_color": "#ffffff", | ||
| "display": "standalone", | ||
| "display_override": ["standalone"], | ||
| "scope": "/", | ||
| "start_url": "/", | ||
| "short_name": "My WordPress", | ||
| "description": "A WordPress directly in your browser: personal, private, and persistent.", | ||
| "name": "My WordPress", | ||
| "categories": ["productivity", "utilities"], | ||
| "screenshots": [ | ||
| { | ||
| "src": "ogimage-mywp.png", | ||
| "sizes": "1200x600", | ||
| "type": "image/png", | ||
| "form_factor": "wide" | ||
| } | ||
| ], | ||
| "icons": [ | ||
| { | ||
| "src": "logo-192.png", | ||
| "sizes": "192x192", | ||
| "type": "image/png" | ||
| "type": "image/png", | ||
| "purpose": "any" | ||
| }, | ||
| { | ||
| "src": "logo-256.png", | ||
| "sizes": "256x256", | ||
| "type": "image/png" | ||
| "type": "image/png", | ||
| "purpose": "any" | ||
| }, | ||
| { | ||
| "src": "logo-384.png", | ||
| "sizes": "384x384", | ||
| "type": "image/png" | ||
| "type": "image/png", | ||
| "purpose": "any" | ||
| }, | ||
| { | ||
| "src": "logo-512.png", | ||
| "sizes": "512x512", | ||
| "type": "image/png" | ||
| "type": "image/png", | ||
| "purpose": "any" | ||
| }, | ||
| { | ||
| "src": "maskable-icon-512.png", | ||
| "sizes": "512x512", | ||
| "type": "image/png", | ||
| "purpose": "maskable" | ||
| } | ||
| ] | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions
79
packages/playground/personal-wp/src/lib/pwa-manifest.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { readFileSync } from 'node:fs'; | ||
| import { joinPaths } from '@php-wasm/util'; | ||
|
|
||
| const appRoot = joinPaths(process.cwd(), 'packages/playground/personal-wp'); | ||
|
|
||
| describe('PWA manifest configuration', () => { | ||
| it('includes install metadata, screenshots, and maskable icons', () => { | ||
| const manifest = readJson('public/manifest.json'); | ||
|
|
||
| expect(manifest).toMatchObject({ | ||
| id: '/', | ||
| display: 'standalone', | ||
| display_override: ['standalone'], | ||
| scope: '/', | ||
| start_url: '/', | ||
| categories: ['productivity', 'utilities'], | ||
| }); | ||
| expect(manifest.screenshots).toEqual([ | ||
| expect.objectContaining({ | ||
| src: 'ogimage-mywp.png', | ||
| sizes: '1200x600', | ||
| form_factor: 'wide', | ||
| }), | ||
| ]); | ||
| expect(manifest).not.toHaveProperty('shortcuts'); | ||
| expect(manifest.icons).toEqual( | ||
| expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| src: 'maskable-icon-512.png', | ||
| sizes: '512x512', | ||
| purpose: 'maskable', | ||
| }), | ||
| ]) | ||
| ); | ||
| }); | ||
|
|
||
| it('adds iOS install metadata and links the production dynamic manifest', () => { | ||
| const html = readText('index.html'); | ||
|
|
||
| expect(html).toMatch( | ||
| /<link\b(?=[^>]*\brel="apple-touch-icon")(?=[^>]*\bhref="\/apple-touch-icon\.png")[^>]*>/ | ||
| ); | ||
| expect(html).toMatch( | ||
| /<meta\b(?=[^>]*\bname="apple-mobile-web-app-capable")(?=[^>]*\bcontent="yes")[^>]*>/ | ||
| ); | ||
| expect(html).toMatch( | ||
| /<meta\b(?=[^>]*\bname="apple-mobile-web-app-title")(?=[^>]*\bcontent="My WordPress")[^>]*>/ | ||
| ); | ||
| expect(html).toContain('/dynamic-manifest.json.php'); | ||
| expect(html).toContain( | ||
| "window.location.pathname.startsWith('/website-server/')" | ||
| ); | ||
| expect(html).not.toContain('if (!manifestUrl)'); | ||
| }); | ||
|
|
||
| it('keeps dynamic manifest identity stable across cache-busting URLs', () => { | ||
| const php = readText('public/dynamic-manifest.json.php'); | ||
|
|
||
| expect(php).toContain('function getManifestId($start_url)'); | ||
| expect(php).toContain("unset($query['random']);"); | ||
| expect(php).toContain('"id" => getManifestId($start_url)'); | ||
| expect(php).toContain('"scope" => $base_url . "/"'); | ||
| expect(php).toContain("$_SERVER['HTTP_HOST']"); | ||
| expect(php).not.toContain('getTrustedBaseUrl'); | ||
| expect(php).toContain(" : '/'"); | ||
| expect(php).not.toContain('"shortcuts" =>'); | ||
| expect(php).toContain( | ||
| "$app_name = $_GET['app_name'] ?? 'My WordPress';" | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| function readJson(relativePath: string) { | ||
| return JSON.parse(readText(relativePath)); | ||
| } | ||
|
|
||
| function readText(relativePath: string) { | ||
| return readFileSync(joinPaths(appRoot, relativePath), 'utf8'); | ||
| } |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's export an isDevServer function from the remote package and reuse it here. There are a few more dev servers we should support https://github.com/bgrgicak/wordpress-playground/blob/77a9939a22962b51d55bb08f3681d231a4db1c3a/packages/playground/remote/src/lib/offline-mode-cache.ts#L173-L187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Bero. I have moved to a separate module