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

Blueprint Builder #773

Merged
merged 39 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
296c863
RunSqlFileStep.
seanmorris Nov 14, 2023
11b49cd
@sejas' original builder.
seanmorris Nov 22, 2023
105691c
@artpi's changes
seanmorris Nov 22, 2023
9314328
My changes.
seanmorris Nov 22, 2023
c9dd9ac
My changes.
seanmorris Nov 22, 2023
2c460bc
PR comments & tweaks.
seanmorris Nov 27, 2023
9cd7632
RunSqlFileStep.
seanmorris Nov 14, 2023
afcca2a
@sejas' original builder.
seanmorris Nov 22, 2023
120dda7
My changes.
seanmorris Nov 22, 2023
cce151e
My changes.
seanmorris Nov 22, 2023
6f262fa
Rebase conflict
seanmorris Nov 27, 2023
ac47ba9
Replacing unpkg urls
seanmorris Nov 27, 2023
b62ea14
Using schema reader.
seanmorris Nov 29, 2023
76db23d
Merge conflict res
seanmorris Nov 29, 2023
ee9e271
Architecture
seanmorris Dec 1, 2023
daadd83
Architecture
seanmorris Dec 1, 2023
ce65295
Reverting package.lock changes.
seanmorris Dec 1, 2023
a033341
Correcting default config
seanmorris Dec 1, 2023
d77cbc3
Correcting URL
seanmorris Dec 1, 2023
f803380
Config.
seanmorris Dec 2, 2023
adb48ec
Tweaks
seanmorris Dec 2, 2023
6968472
Comment
seanmorris Dec 4, 2023
08d8255
Removing AI UI.
seanmorris Dec 4, 2023
4696e11
Production URLs
seanmorris Dec 4, 2023
e62e799
Reverting extraneous changes
seanmorris Dec 4, 2023
ee2b93b
Merge branch 'trunk' into sm-bp-builder
seanmorris Dec 4, 2023
153b734
Reverting extraneous changes
seanmorris Dec 4, 2023
7c5bf01
Reverting extra changes.
seanmorris Dec 4, 2023
8da27b2
Merge branch 'trunk' into sm-bp-builder
seanmorris Dec 4, 2023
dcca302
Fixing lint error.
seanmorris Dec 4, 2023
55763da
Fixing lint error.
seanmorris Dec 4, 2023
867adbf
Fixing lint error.
seanmorris Dec 4, 2023
498bf09
Fixing lint error.
seanmorris Dec 4, 2023
861a628
Removing comments.
seanmorris Dec 4, 2023
9d6a08d
Removing comments.
seanmorris Dec 4, 2023
6417035
Update packages/playground/website/vite.config.ts
seanmorris Dec 4, 2023
90c0e44
Reverting.
seanmorris Dec 5, 2023
af4b5a2
Merge branch 'sm-bp-builder' of github.com:seanmorris/wordpress-playg…
seanmorris Dec 5, 2023
5ab1e8b
Merge branch 'trunk' into sm-bp-builder
seanmorris Dec 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can connect to the Playground using the JavaScript client. Here's an example
<!DOCTYPE html>
<iframe id="wp-playground" style="width: 1200px; height: 800px"></iframe>
<script type="module">
import { startPlaygroundWeb } from 'https://unpkg.com/@wp-playground/client/index.js';
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp-playground'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ You can also use Blueprints with the JavaScript API using the `startPlaygroundWe
```html
<iframe id="wp-playground" style="width: 1200px; height: 800px"></iframe>
<script type="module">
import { startPlaygroundWeb } from 'https://unpkg.com/@wp-playground/client/index.js';
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp-playground'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 3
The Playground API client can be initialized with a [JSON Blueprint](../09-blueprints-api/01-index.md). This is a convenient way of preconfiguring it in any way you like without worrying about progress bars and fetching remote files:

```ts
import { startPlaygroundWeb } from 'https://unpkg.com/@wp-playground/client/index.js';
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Every Blueprint step you can declare in the JSON object also provides a handler
For example:

```ts
import { startPlaygroundWeb, login, installPlugin } from 'https://unpkg.com/@wp-playground/client/index.js';
import { startPlaygroundWeb, login, installPlugin } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
></iframe>
<script type="module">
// Use unpkg for convenience
import { startPlaygroundWeb } from 'https://unpkg.com/@wp-playground/client/index.js';
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
Expand Down
5 changes: 4 additions & 1 deletion packages/php-wasm/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export default defineConfig(({ command }) => {
* import("./php_8_2.js")
* and not
* import("php_8_2.js")
*
* The slice(-2) will ensure the 'kitchen-sink' or 'light'
* portion of the path is preserved.
*/
return '../' + specifier.split('/').pop();
return '../' + specifier.split('/').slice(-2).join('/');
adamziel marked this conversation as resolved.
Show resolved Hide resolved
}
},
},
Expand Down
17 changes: 17 additions & 0 deletions packages/playground/blueprints/src/lib/steps/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ export async function fileToUint8Array(file: File) {
* Import the polyfilled File class below to ensure its buffer is available to
* functions like writeFile (./client-methods.ts) and fileToUint8Array (above).
*/

globalThis.File =
globalThis.File ||
class extends Blob {
lastModified = 0;
constructor(
bits: any,
name: string,
options: { type?: string; lastModified?: number }
) {
super(bits);
if (options.lastModified) {
this.lastModified = options.lastModified;
}
}
};

Copy link
Collaborator

@adamziel adamziel Dec 5, 2023

Choose a reason for hiding this comment

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

Is this change required by the Blueprints builder or can it be safely removed from this PR? Polyfilling the File class seems like a distinct issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamziel I originally figured we could roll that update into this one, but you're right, we need to keep it separate. I've got another branch for that now.

class FilePolyfill extends File {
buffers: BlobPart[];
constructor(buffers: BlobPart[], name: string) {
Expand Down
5 changes: 5 additions & 0 deletions packages/playground/website/builder/brain.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
223 changes: 223 additions & 0 deletions packages/playground/website/builder/builder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WordPress Playground Blueprint Builder</title>
<link
href="https://cdn.jsdelivr.net/npm/ace-builds@1.31.2/css/ace.min.css"
rel="stylesheet"
/>
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.31.2/src-min-noconflict/ace.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.31.2/src-min-noconflict/ext-language_tools.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="builder.js" type="module"></script>
</head>
<body>
<div class="playground-wrapper">
<main>
<div class="column editor">
<div class="toolbar">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<!-- Spinner Adapted from: https://github.com/n3r4zzurr0/svg-spinners/ -->
<g>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
opacity=".14"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(30 12 12)"
opacity=".29"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(60 12 12)"
opacity=".43"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(90 12 12)"
opacity=".57"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(120 12 12)"
opacity=".71"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(150 12 12)"
opacity=".86"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(180 12 12)"
/>
<animateTransform
attributeName="transform"
type="rotate"
calcMode="discrete"
dur="0.333s"
values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12"
repeatCount="indefinite"
/>
</g>
</svg>
<span>⌘ ctrl + space: show autocomplete</span>
<span class="spacer"></span>
<span>⌘ ctrl + enter:</span>
<button id="run" class="cta run">RUN IT</button>
<button id="save" aria-label="save"></button>
<button id="open" aria-label="open"></button>
</div>
<section id="ai">
<textarea
id="prompt"
placeholder="What kind of website do you want?"
></textarea>
<div class="toolbar">
<button id="close-ai" class="close"></button>
<span class="spacer"></span>
<button id="generate" class="generate">
GENERATE
</button>
</div>
</section>
Comment on lines +107 to +119
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment for posterity – let's remove this part of the HTML.

<pre
id="jsontext"
class="json-container"
contenteditable="true"
></pre>
<div class="frame-wrapper">
<iframe id="error-output"></iframe>
</div>
</div>
<div class="separator"></div>
<div class="column viewer">
<div class="toolbar">
<span class="spacer"></span>
<button id="new-tab">OPEN IN NEW TAB</button>
</div>
<div class="frame-wrapper">
<div class="frame-center">
<svg
width="32"
height="32"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<!-- Spinner Adapted from: https://github.com/n3r4zzurr0/svg-spinners/ -->
<g>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
opacity=".14"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(30 12 12)"
opacity=".29"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(60 12 12)"
opacity=".43"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(90 12 12)"
opacity=".57"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(120 12 12)"
opacity=".71"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(150 12 12)"
opacity=".86"
/>
<rect
fill="#fff"
x="11"
y="1"
width="2"
height="5"
transform="rotate(180 12 12)"
/>
<animateTransform
attributeName="transform"
type="rotate"
calcMode="discrete"
dur="0.5s"
values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12"
repeatCount="indefinite"
/>
</g>
</svg>
</div>
<iframe id="wp-playground"></iframe>
</div>
</div>
</main>
</div>
</body>
</html>
Loading
Loading