Skip to content
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

OPFS: Migrate to the latest spec #547

Merged
merged 10 commits into from
Jun 15, 2023
Merged

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Jun 14, 2023

Description

Previous implementation of OPFS sync used deprecated webkitRequestFileSystem and only worked in Chrome-based browser.

This commit migrates to the modern FileSystem API which means it can be also used on Safari, Firefox, and mobile:

https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

CleanShot 2023-06-14 at 16 53 50@2x

Testing Instructions

Select "Persistent site" in the mode picker and confirm your changes are preserved between page refreshes:

  1. Create a post
  2. Install a plugin
  3. Delete a plugin

cc @dmsnell

Comment on lines +18 to +19
const zipName = 'wordpress-playground.zip';
const zipPath = `/tmp/${zipName}`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is somewhat unrelated but I found Safari refused to download the exported file without this

@dmsnell
Copy link
Member

dmsnell commented Jun 14, 2023

Do we have a clear and easy reset button to click on to wipe out everything?

@adamziel
Copy link
Collaborator Author

adamziel commented Jun 14, 2023

Yup, that's a necessary feature. I don't love the crowded toolbar – it could use some iterating

CleanShot 2023-06-14 at 16 31 02@2x

adamziel added a commit that referenced this pull request Jun 14, 2023
Since #547 adds support for OPFS API, I just realized the same API can
be used to read/write local files. This PR adds a local directory picker
and a "refresh" button to bring the changes back into Playground's
MEMFS.

The Toolbar is getting really crowded, let's add a hamburger menu for
now before merging this PR. In the future, let's find out a better UI
solution than a hamburger menu.
adamziel added 3 commits June 15, 2023 10:04
Previous implementation of OPFS sync used deprecated
webkitRequestFileSystem and only worked in Chrome-based browser.

This commit migrates to the modern FileSystem API which means it
can be also used on Safari, Firefox, and more:

https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
…o switch to a temporary site or nuke everything if needed.
@adamziel adamziel force-pushed the use-latest-filesystem-api-spec branch from 16ebe4d to 1fa4f00 Compare June 15, 2023 08:05
@adamziel adamziel force-pushed the use-latest-filesystem-api-spec branch from 1fa4f00 to bbda40c Compare June 15, 2023 08:06
@adamziel adamziel force-pushed the use-latest-filesystem-api-spec branch from b19c3a1 to 163afe7 Compare June 15, 2023 10:56
@adamziel adamziel merged commit 69d82ac into trunk Jun 15, 2023
@adamziel adamziel deleted the use-latest-filesystem-api-spec branch June 15, 2023 11:23
@dmsnell
Copy link
Member

dmsnell commented Jun 15, 2023

@adamziel considering the "Install Plugins UI" makes me think about a ⚙️ settings icon in the top right. open that and you pick all these things. could be a good model for all these settings.

@adamziel
Copy link
Collaborator Author

adamziel commented Jun 16, 2023

@dmsnell we have this now – it should be a good platform for future iterations:

CleanShot 2023-06-16 at 16 15 23@2x CleanShot 2023-06-16 at 16 13 47@2x

I avoided a single unlabeled settings icon because:

adamziel added a commit that referenced this pull request Jun 22, 2023
Since #547 adds
support for OPFS API, I just realized the same API can be used to
read/write local files. This PR adds a local directory picker and a
"Sync local files" button to bring the changes back into Playground's MEMFS.
Pookie717 added a commit to Pookie717/wordpress-playground that referenced this pull request Oct 1, 2023
Since WordPress/wordpress-playground#547 adds
support for OPFS API, I just realized the same API can be used to
read/write local files. This PR adds a local directory picker and a
"Sync local files" button to bring the changes back into Playground's MEMFS.
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