@playcademy/vite-plugin 0.1.19 → 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.
- package/README.md +7 -3
- package/dist/index.js +12 -12
- package/package.json +2 -2
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:
|
|
177
|
-
➜ Sandbox:
|
|
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="/
|
|
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 = '/
|
|
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="/
|
|
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 = '/
|
|
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
|
-
|
|
205752
|
-
|
|
205753
|
-
|
|
205754
|
-
|
|
205755
|
-
|
|
205756
|
-
|
|
205757
|
-
|
|
205758
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"archiver": "^7.0.1",
|
|
27
27
|
"picocolors": "^1.1.1",
|
|
28
|
-
"playcademy": "0.13.
|
|
28
|
+
"playcademy": "0.13.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@inquirer/prompts": "^7.8.6",
|