-
Notifications
You must be signed in to change notification settings - Fork 3
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
Load client from playground.wordpress.net instead of @wp-playground/client #79
Comments
I'm not sure I understand how this would work, could you clarify how we would use the client from |
Like this: <iframe id="wp" style="width: 100%; height: 700px; border: 1px solid #000;"></iframe>
<script type="module">
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';
try {
const mountDescriptor = {
device: {
type: 'opfs',
path: '/try-wp-zz',
},
mountpoint: '/wordpress',
};
const isWordPressInstalled = confirm('Is WordPress installed? Ok=yes; Cancel=no;');
console.log( isWordPressInstalled ? 'WP: Already Installed' : 'WP: Not Installed' );
const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
remoteUrl: `https://playground.wordpress.net/remote.html`,
mounts: [mountDescriptor],
shouldInstallWordPress: ! isWordPressInstalled,
});
await client.isReady();
window.pgclient = client;
} catch (error) {
console.error("pg client", error);
}
</script> |
Thanks for clarifying. This might might make it a little better, but I see some invonveniences:
I think ultimately, the best solution would be to package playground into the extension. If that's not possible, for reasons outside our control (e.g. browser limitations), another possibility would be for playground.wordpress.net to provide multiple versions, e.g. https://playground.wordpress.net/v0.1.2. |
Agree! Or we can host our own instance |
I want to avoid breaking changes in For non-breaking changes, loading the client from playground.wordpress.net would actually keep the browser extension working – the client would be auto-updated in the same deployment as remote.html.
Isn't that true for any technique of importing the client?
Isn't there a way to configure TypeScript to still get types? Like an import map in tsconfig.json?
Yup, that would work too. If you host it on the atomic platform, you should be able to just fork the Playground repo and reuse the same deployment scripts. |
Sorry, I think my maybe comment above didn't make clear what I meant. The bisect comment related to a scenario where everything the extension needs to operate is bundled within the extension, and we control the exact versions of everything. In this scenario, once the user installed the extension, they would be able to turn off the network, and everything would still work. (To be clear I'm not saying that offline functionality is a feature we should care about, I'm just using it to illustrate the point). In practice, this would mean that a specific version of Playground, along with a specific version of WordPress would be bundled into the extension. We would then reference the I can see several advantages with such an approach:
We could still make it possible for the user to be on the "bleeding edge" if they so desire, through a setting, for example. I don't know if bundling everything into the extension is technically feasible, but I think it would allow us to provide a more stable experience. |
Oh I would love a reusable setup for shipping Playground inside an extension in a way that works across web browsers. It all depends on your apetite — it would likely take a few weeks to get it right and it may still require an external domain for the service worker. Check out the "edit visually" browser extension from the playground-tools repo (and the PR exploring v2) for prior art. |
@adamziel made the suggestion to use the client from
playground.wordpress.net
itself to have a version that’s always synchronized with the Playground versionThe text was updated successfully, but these errors were encountered: