From 3f9be376f9919e75d6b79675325d04318eae242c Mon Sep 17 00:00:00 2001
From: Marc Armengou <83702259+MarcArmengou@users.noreply.github.com>
Date: Thu, 5 Oct 2023 14:55:54 +0200
Subject: [PATCH] Renamed the param opfs-browser from Query API, to browser
(#651)
## What is this PR doing?
Changed the param 'opfs-browser' to 'browser' as discussed at:
https://github.com/WordPress/wordpress-playground/issues/636
Kept the old names working, for now.
## What problem does it solve?
Renamed the opfs-browser parameter to simply browser, to make it easier
for users to remember.
---
packages/docs/site/docs/08-query-api/01-index.md | 2 +-
packages/playground/remote/src/lib/worker-thread.ts | 6 +++---
.../components/playground-configuration-group/form.tsx | 8 ++++----
.../components/playground-configuration-group/index.tsx | 8 ++++----
.../reload-with-new-configuration.ts | 4 ++--
packages/playground/website/src/lib/hooks.ts | 2 +-
packages/playground/website/src/types.ts | 2 +-
7 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/packages/docs/site/docs/08-query-api/01-index.md b/packages/docs/site/docs/08-query-api/01-index.md
index 120b7e1f32..e69e0e2c63 100644
--- a/packages/docs/site/docs/08-query-api/01-index.md
+++ b/packages/docs/site/docs/08-query-api/01-index.md
@@ -32,7 +32,7 @@ You can go ahead and try it out. The Playground will automatically install the t
| `lazy` | | Defer loading the Playground assets until someone clicks on the "Run" button |
| `login` | `1` | Logs the user in as an admin |
| `gutenberg-pr` | | Loads the specified Gutenberg Pull Request |
-| `storage` | | Selects the storage for Playground: `temporary` gets erased on page refresh, `opfs-browser` is stored in the browser, and `opfs-host` is stored in the selected directory on a local computer. The last two protect the user from accidentally losing their work upon page refresh. |
+| `storage` | | Selects the storage for Playground: `temporary` gets erased on page refresh, `browser` is stored in the browser, and `opfs-host` is stored in the selected directory on a device. The last two protect the user from accidentally losing their work upon page refresh. |
For example, the following code embeds a Playground with a preinstalled Gutenberg plugin, and opens the post editor:
diff --git a/packages/playground/remote/src/lib/worker-thread.ts b/packages/playground/remote/src/lib/worker-thread.ts
index 8fe72b2033..b5c8ac2ad6 100644
--- a/packages/playground/remote/src/lib/worker-thread.ts
+++ b/packages/playground/remote/src/lib/worker-thread.ts
@@ -55,9 +55,9 @@ let virtualOpfsDir: FileSystemDirectoryHandle | undefined;
let lastOpfsDir: FileSystemDirectoryHandle | undefined;
let wordPressAvailableInOPFS = false;
if (
- startupOptions.storage === 'opfs-browser' &&
- // @ts-ignore
- typeof navigator?.storage?.getDirectory !== 'undefined'
+ (startupOptions.storage === 'opfs-browser' || startupOptions.storage === 'browser') &&
+ // @ts-ignore
+ typeof navigator?.storage?.getDirectory !== 'undefined'
) {
virtualOpfsRoot = await navigator.storage.getDirectory();
virtualOpfsDir = await virtualOpfsRoot.getDirectoryHandle('wordpress', {
diff --git a/packages/playground/website/src/components/playground-configuration-group/form.tsx b/packages/playground/website/src/components/playground-configuration-group/form.tsx
index 6ea8cfb957..81e21adf50 100644
--- a/packages/playground/website/src/components/playground-configuration-group/form.tsx
+++ b/packages/playground/website/src/components/playground-configuration-group/form.tsx
@@ -124,14 +124,14 @@ export function PlaygroundConfigurationForm({