@playcademy/vite-plugin 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +7 -3
  2. package/dist/index.js +12 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -162,6 +162,7 @@ During `bun dev`, the plugin:
162
162
  - Starts the sandbox server (if enabled)
163
163
  - Provides game API simulation
164
164
  - Enables hot reload for game code
165
+ - Seamlessly wraps your game in the Playcademy environment
165
166
 
166
167
  Console output:
167
168
 
@@ -173,11 +174,14 @@ VITE v6.3.5 ready in 500ms
173
174
 
174
175
  PLAYCADEMY v1.2.3
175
176
 
176
- ➜ Game: my-game
177
- ➜ Sandbox: http://localhost:4321/api
178
- ➜ Realtime: ws://localhost:4322
177
+ ➜ Game: my-game
178
+ ➜ Sandbox: http://localhost:4321/api
179
179
  ```
180
180
 
181
+ **How it works**: When you visit `http://localhost:5173/` in your browser, you'll see your game wrapped in the Playcademy development shell (which mimics the production platform environment). Inside the iframe, your game is served at the root path `/`, so client-side routers (React Router, etc.) work naturally without any special configuration.
182
+
183
+ The plugin uses the `Sec-Fetch-Dest` header to intelligently detect whether a request is from the shell's iframe or top-level browser navigation, automatically serving the appropriate content.
184
+
181
185
  ### Production Build
182
186
 
183
187
  During `bun run build`, the plugin:
package/dist/index.js CHANGED
@@ -205378,7 +205378,7 @@ var shell_no_badge_default = `<!doctype html>
205378
205378
  ></div>
205379
205379
  </div>
205380
205380
 
205381
- <iframe class="game-frame hidden" id="gameFrame" src="/game"></iframe>
205381
+ <iframe class="game-frame hidden" id="gameFrame" src="/"></iframe>
205382
205382
  </div>
205383
205383
 
205384
205384
  <script type="module">
@@ -205479,7 +205479,7 @@ var shell_no_badge_default = `<!doctype html>
205479
205479
  stopHandshake()
205480
205480
  })
205481
205481
 
205482
- gameFrame.src = '/game'
205482
+ gameFrame.src = '/'
205483
205483
  }
205484
205484
 
205485
205485
  window.addEventListener('message', event => {
@@ -205608,7 +205608,7 @@ var shell_with_corner_badge_default = `<!doctype html>
205608
205608
  ></div>
205609
205609
  </div>
205610
205610
 
205611
- <iframe class="game-frame hidden" id="gameFrame" src="/game"></iframe>
205611
+ <iframe class="game-frame hidden" id="gameFrame" src="/"></iframe>
205612
205612
  </div>
205613
205613
 
205614
205614
  <script type="module">
@@ -205714,7 +205714,7 @@ var shell_with_corner_badge_default = `<!doctype html>
205714
205714
  stopHandshake()
205715
205715
  })
205716
205716
 
205717
- gameFrame.src = '/game'
205717
+ gameFrame.src = '/'
205718
205718
  }
205719
205719
 
205720
205720
  window.addEventListener('message', event => {
@@ -205748,14 +205748,14 @@ function generateLoaderHTML(sandboxUrl, gameId, realtimeUrl, showBadge, gameUrl)
205748
205748
  function devServerMiddleware(server, sandbox, gameUrl, showBadge) {
205749
205749
  server.middlewares.use("/", (req, res, next) => {
205750
205750
  if (req.url === "/" && req.method === "GET") {
205751
- res.setHeader("Content-Type", "text/html");
205752
- const gameId = sandbox.project?.slug;
205753
- res.end(generateLoaderHTML(sandbox.baseUrl, gameId ?? "", sandbox.realtimeUrl, showBadge, gameUrl));
205754
- return;
205755
- }
205756
- if (req.url === "/game" && req.method === "GET") {
205757
- req.url = "/index.html";
205758
- next();
205751
+ const secFetchDest = req.headers["sec-fetch-dest"];
205752
+ if (secFetchDest === "iframe") {
205753
+ next();
205754
+ } else {
205755
+ res.setHeader("Content-Type", "text/html");
205756
+ const gameId = sandbox.project?.slug;
205757
+ res.end(generateLoaderHTML(sandbox.baseUrl, gameId ?? "", sandbox.realtimeUrl, showBadge, gameUrl));
205758
+ }
205759
205759
  return;
205760
205760
  }
205761
205761
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/vite-plugin",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {