-
Notifications
You must be signed in to change notification settings - Fork 385
[website] Introduce a Personal Playground mode #3155
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
base: trunk
Are you sure you want to change the base?
Conversation
2899417 to
c278f6e
Compare
9863d74 to
02c9df6
Compare
9a28a1f to
90b5665
Compare
Add infrastructure for persistent WordPress sites that survive browser sessions: - Add virtual:website-defaults Vite plugin for build-time configuration (defaultStorageType, defaultSiteSlug, defaultBlueprintUrl) - Create PersistentBrowserChrome component with separate styling - Create PersistentPlaygroundOverlay with "More Playgrounds" link and "Start over" delete functionality - Add persistent-playground module for blueprint loading - Track lastUrl in SiteMetadata to restore user position on return - Auto-login for persistent sites when returning - Persist site metadata to OPFS on creation - Run both dev servers in parallel (port 5400 standard, 5401 persistent) - Use "default" site slug to keep URLs clean This is a foundational PR for persistent deployment. Multi-tab coordination, pending URL blueprints, and other advanced features will be added in subsequent PRs.
Enable applying blueprints to existing persistent sites via URL params like ?plugin=friends or ?blueprint-url=data:... - Add PendingUrlBlueprint interface and state to slice-sites - Add resolveUrlParamsForExistingSite to detect actionable URL params - Store pending blueprint when returning to existing default site - Merge pending blueprint steps into boot blueprint - Clear pending blueprint and URL params after successful boot
90b5665 to
eeb8f50
Compare
packages/playground/website/src/components/personal-browser-chrome/index.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| import css from './style.module.css'; | ||
| import BrowserChrome from '../browser-chrome'; | ||
| import PersonalBrowserChrome from '../personal-browser-chrome'; |
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.
How could we do code splitting here to avoid adding these components into playground.wordpress.net build.js bundle?
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.
I added a React.lazy and verified that the PersonalWP components are in a separate lazy-loaded chunk:
# Fresh production build, checking for PersonalWP-specific content ("Start over" button text)
$ grep -l "Start over" dist/packages/playground/website/assets/*.js
index-CxgH81pX.js # Lazy chunk only
$ grep -c "Start over" dist/packages/playground/website/assets/main-*.js
0 # Not in main bundle
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! We also need to consider the impact on packages/vite-extensions/vite-list-assets-required-for-offline-mode.ts. The offline mode won't work until all those files are cached so we don't want to put the PersonalWP assets on the core Playground offline assets list.
We roughly have two possible solutions here:
- Output a separate list of required assets for Playground and PersonalWP. This is ideal but might not be easy and maybe shouldn't block this work.
- Break the offline mode support in PersonalWP for the time being, and exclude PersonalWP bundle files from the list of required assets. We could do that by storing them in, say,
dist/packages/playground/website/assets/personalwp/and adding that as a regexp to packages/vite-extensions/vite-list-assets-required-for-offline-mode.ts.
A third option, that would take care of 1 and 2 but would also make the maintenance more annoying, would be to just copy the entire website package as personal-wp and duplicate everything. It has its own upsides and downsides, but would solve for this particular problem.
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
packages/playground/website/src/lib/state/redux/boot-site-client.ts
Outdated
Show resolved
Hide resolved
- Rename personal-* folders and components to personalwp-* - Rename variables: defaultSiteSlug -> personalWPSiteSlug, isPersonalMode -> isPersonalWPMode, shouldUsePersonalBlueprint -> shouldUsePersonalWPBlueprint - Rename PendingUrlBlueprint -> BlueprintResolvedFromUrl with siteSlug -> targetSiteSlug for clarity - Apply lastUrl persistence to all sites (not just storage !== none) - Restrict URL param clearing to PersonalWP only and also clear hash
This ensures the PersonalWP components are not included in the playground.wordpress.net bundle, only loaded when needed.
Add BootSiteClientOptions interface with: - clearUrlAfterBlueprintApplied: clears URL params and hash after boot - autoLogin: enables auto-login when WordPress is already installed This removes the implicit dependency on personalWPSiteSlug inside the function and makes the behavior explicit at the call site.
- Mode: personal -> personalwp, personal-development -> personalwp-development - Blueprint: personal-boot.json -> personalwp-boot.json - Cache dir: packages-playground-website-personal -> packages-playground-website-personalwp - Config: personalWebsiteDevServerPort -> personalwpWebsiteDevServerPort
| const activeSite = useActiveSite(); | ||
|
|
||
| // Personal mode uses JustViewport directly (no keep-alive needed since data is in OPFS) | ||
| if (defaultStorageType === 'opfs') { |
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.
This if is pretty generic. It looks a bit as if Playground had a concept of defaultStorageType that it does not have. When it does, the implementation may differ. Let's disambiguate the naming here and just say if (insidePersonalWp) { or something to that effect that tells us directly "ah, this is another app and it does things a bit differently".
Keep personal-wp as a fully separate package without modifying the original playground-website codebase.
- Remove unused opfsMountDescriptor variable in site-info-panel - Reorder imports to top of file in vite.config.ts
Based on #3152.
Motivation for the change, related issues
Adds a
persistentpersonalwp deployment mode where WordPress sites are stored in OPFS and survive browser sessions.To avoid conflicts with other (earlier) uses of
persistentacross the code base.Implementation details
virtual:website-defaultsVite plugin for build-time configuration (defaultStorageType,personalWPSiteSlug,defaultBlueprintUrl)PersonalWPBrowserChromeandPersonalWPOverlaycomponents (lazy-loaded to avoid bundling in playground.wordpress.net)lastUrltracking in site metadata to restore user position on return?plugin=friendsor?blueprint-url=data:...are applied to existing sites, then URL is clearedbootSiteClient()withclearUrlAfterBlueprintAppliedandautoLoginoptionsScreenshot
The new overlay:
Testing Instructions (or ideally a Blueprint)
npm run dev(starts both servers)?plugin=friends- the plugin should be installed on the existing site, URL params cleared after