Skip to content

Commit 23d3338

Browse files
committed
Use WordPress runner for Figma imports
1 parent 46bf880 commit 23d3338

11 files changed

Lines changed: 153 additions & 567 deletions

File tree

docs/figma-playground-runner.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Figma to WordPress
22

3-
`plugins/figma-to-wordpress` moves a Figma file into WordPress. Internally it generates a static HTML/CSS website artifact, then hands that artifact to a WordPress Playground runner that imports it with Static Site Importer and Blocks Engine.
3+
`plugins/figma-to-wordpress` moves a Figma file into WordPress. It hands the design to a WordPress runner service that creates a Playground session and imports the result with Static Site Importer and Blocks Engine.
44

55
## Architecture
66

77
```text
88
Figma plugin UI
9-
-> GeneratedWebsiteArtifact
10-
-> PlaygroundRunnerPayload
11-
-> runner URL or generated runner page
12-
-> WordPress Playground blueprint
9+
-> Figma document scene data
10+
-> runner request
11+
-> WordPress runner service
12+
-> WordPress Playground session URL
1313
-> Static Site Importer / Blocks Engine inside WordPress
1414
```
1515

16-
The TypeScript boundary stops at payload construction and Playground blueprint creation. WordPress, PHP, Static Site Importer, and Blocks Engine remain WordPress-side runtime concerns.
16+
The TypeScript boundary stops at request construction and opening the returned Playground URL. WordPress, PHP, Static Site Importer, Blocks Engine, and Playground session orchestration remain WordPress-side runtime concerns.
1717

1818
## Figma Iframe Limits
1919

@@ -27,27 +27,25 @@ Practical constraints for this browser-based flow:
2727
- Clipboard access can require user activation.
2828
- Local file URLs can behave differently between desktop Figma, browser Figma, and development builds.
2929

30-
Because of those constraints, the primary integration shape is a browser fallback: the plugin builds the same runner payload and opens or copies a runner URL. If in-plugin embedding works later, it can consume the same `PlaygroundRunnerPayload` interface.
30+
Because of those constraints, the primary integration shape is a service handoff: the plugin posts a runner request and opens the returned URL in a browser tab. If in-plugin embedding works later, it can consume the same runner response interface.
3131

3232
## Playground And PHP Role
3333

3434
WordPress Playground is the correct place to run WordPress and PHP plugin logic. It provides a browser-hosted WordPress runtime backed by WebAssembly PHP and a virtual filesystem.
3535

36-
Static Site Importer and Blocks Engine should run in that WordPress runtime because they are WordPress/PHP import systems. The Figma plugin should not reimplement them in TypeScript. The plugin's job is to hand off a generated static artifact with enough metadata for the Playground runner to install/activate/import with those plugins.
36+
Static Site Importer and Blocks Engine should run in that WordPress runtime because they are WordPress/PHP import systems. The Figma plugin should not reimplement them in TypeScript. The plugin's job is to hand off design data with enough metadata for the WordPress runner to transform, install, activate, and import with those plugins.
3737

3838
## Current Boundary
3939

4040
Implemented now:
4141

4242
- `GeneratedWebsiteArtifact` for static generated files from Figma.
43-
- `PlaygroundRunnerPayload` for the Playground handoff plan.
44-
- Runner URL construction with an encoded payload fragment.
45-
- A standalone runner HTML page that decodes and displays the payload.
46-
- A Playground URL builder that installs Static Site Importer from GitHub, writes the artifact JSON into `/tmp/figma-to-wordpress-artifact.json`, and runs the `static-site-importer/import-website-artifact` ability.
43+
- `figma-to-wordpress/runner-request/v1` for the runner handoff plan.
44+
- A Figma UI client that posts the runner request and opens the returned Playground URL.
4745

4846
Not implemented yet:
4947

50-
- Embedded Playground execution inside the Figma iframe.
48+
- The hosted WordPress runner endpoint that creates the Playground session.
5149
- Post-import block validation and visual parity checks.
5250

5351
## Local Testing
@@ -60,21 +58,14 @@ npm run build --prefix plugins/figma-to-wordpress
6058
npm test --prefix plugins/figma-to-wordpress
6159
```
6260

63-
Manual runner test:
64-
65-
1. Build or otherwise serve `plugins/figma-to-wordpress/runner/playground-runner.html`.
66-
2. Use `buildRunnerPayload()` and `buildRunnerUrl()` from `src/payload.ts` to create a URL with `#payload=...`.
67-
3. Open the URL in a browser.
68-
4. Confirm the payload is decoded and the Playground link opens a session that installs Static Site Importer and runs the artifact import.
69-
7061
Figma development test:
7162

7263
1. Run `npm run build --prefix plugins/figma-to-wordpress`.
7364
2. Load `plugins/figma-to-wordpress/manifest.json` as a Figma development plugin.
7465
3. Run the plugin.
7566
4. Use `Open in WordPress Playground`.
76-
5. If the runner does not open from inside Figma, paste the copied URL into a normal browser tab.
67+
5. Confirm the runner service returns a Playground URL that opens in a normal browser tab.
7768

7869
## Next Integration Step
7970

80-
The next meaningful step is a hosted runner page with richer progress/error reporting around the Playground import and post-import block/visual validation. That should remain in the WordPress/Playground runner layer, not by porting PHP importer behavior into the Figma plugin.
71+
The next meaningful step is a hosted WordPress runner endpoint with progress/error reporting around the Playground import and post-import block/visual validation. That should remain in the WordPress/Playground runner layer, not by porting PHP importer behavior into the Figma plugin.
Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
# Figma to WordPress
22

3-
This plugin moves a Figma file into WordPress by generating static HTML/CSS internally and importing that artifact with Static Site Importer and Blocks Engine in WordPress Playground.
3+
This plugin moves a Figma file into WordPress by handing the design to a WordPress runner service that imports it with Static Site Importer and Blocks Engine in WordPress Playground.
44

5-
It does not port Static Site Importer, Blocks Engine, WordPress, PHP, or Playground internals to TypeScript. The TypeScript code extracts Figma scene data, builds a static artifact, and creates a Playground blueprint that runs the WordPress/PHP import path.
5+
It does not port Static Site Importer, Blocks Engine, WordPress, PHP, or Playground internals to TypeScript. The TypeScript code extracts Figma scene data, prepares the runner request, and opens the Playground session URL returned by the WordPress-side runner.
66

77
## Flow
88

99
```text
1010
Figma plugin controller + UI
11-
-> selected Figma scene
12-
-> static HTML/CSS website artifact
13-
-> runner payload
14-
-> Playground blueprint URL
15-
-> WordPress Playground boots WordPress/PHP in WASM
16-
-> Static Site Importer installs and imports through Blocks Engine
11+
-> whole Figma document scene data
12+
-> runner request
13+
-> WordPress runner service
14+
-> WordPress Playground session
15+
-> Static Site Importer imports through Blocks Engine
1716
```
1817

1918
## Boundaries
2019

2120
- Implemented: a Figma Desktop-loadable plugin shell with whole-file export.
22-
- Implemented: a reusable scene-to-HTML/CSS artifact generator with diagnostics and tests.
23-
- Implemented: a Playground blueprint URL that installs Static Site Importer from GitHub and calls `static-site-importer/import-website-artifact` with the generated artifact.
24-
- Implemented: a standalone runner page that decodes the payload and opens the same Playground import URL.
21+
- Implemented: a reusable scene-to-HTML/CSS artifact generator with diagnostics and tests for the current local handoff.
22+
- Implemented: a product-neutral runner request that can be posted to a WordPress-side Playground session service.
2523
- Not implemented: running Static Site Importer from TypeScript.
26-
- Not implemented: in-plugin embedded Playground validation; the reliable path opens Playground in a browser tab.
24+
- Not implemented: the hosted WordPress runner endpoint that creates the Playground session and returns its URL.
2725
- Not implemented: automated visual parity/block validation after import.
2826

2927
## Files
@@ -32,17 +30,16 @@ Figma plugin controller + UI
3230
- `src/code.ts` is the Figma plugin main thread entry.
3331
- `src/ui.ts` is the Figma UI-side handoff logic.
3432
- `src/index.ts` contains the reusable Figma-scene-to-website-artifact generator.
35-
- `src/payload.ts` contains the reusable TypeScript interfaces and Playground blueprint URL builders.
33+
- `src/payload.ts` contains the reusable TypeScript interfaces for the runner handoff.
34+
- `src/wordpress-runner.ts` posts the runner request and expects an `open_url` response.
3635
- `src/ui.html` is the Figma UI shell bundled into `dist/ui.html`.
37-
- `runner/playground-runner.html` is the browser fallback runner page.
3836

3937
## Local Test
4038

4139
1. Run `npm run build --prefix plugins/figma-to-wordpress`.
4240
2. In Figma Desktop, use Plugins -> Development -> Import plugin from manifest, then select `plugins/figma-to-wordpress/manifest.json`.
4341
3. Open the plugin and choose `Open in WordPress Playground`.
44-
4. If Figma blocks embedding or navigation, copy the generated runner URL and open it in a normal browser tab.
45-
5. Confirm WordPress Playground boots, installs Static Site Importer, runs the import, and opens wp-admin.
42+
4. Confirm the WordPress runner service returns a Playground URL and the plugin opens it in a browser tab.
4643

4744
For quick syntax verification without a full Figma build pipeline:
4845

@@ -52,8 +49,8 @@ npm run build --prefix plugins/figma-to-wordpress
5249
npm test --prefix plugins/figma-to-wordpress
5350
```
5451

55-
## Figma Iframe Fallback
52+
## Runner Boundary
5653

57-
Figma plugin UIs run in a constrained iframe-like environment. Cross-origin iframes, WASM boot, popup behavior, and navigation can be restricted depending on host context and plugin permissions. The supported fallback is to build the same payload, encode it into a runner URL fragment, and ask the user to open the runner page in a browser tab.
54+
Figma plugin UIs run in a constrained iframe-like environment. Cross-origin iframes, WASM boot, popup behavior, and navigation can be restricted depending on host context and plugin permissions. The supported boundary is a WordPress-side runner service: the plugin posts a runner request, the service creates the Playground session, and the plugin opens the returned URL.
5855

5956
See [`../../docs/figma-playground-runner.md`](../../docs/figma-playground-runner.md) for the integration notes.

0 commit comments

Comments
 (0)