@playcademy/vite-plugin 0.1.20 → 0.1.22

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 +23 -13
  3. package/package.json +3 -3
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
@@ -100152,6 +100152,9 @@ var isDevelopment = () => {
100152
100152
  var isInteractiveTTY = () => {
100153
100153
  return typeof process !== "undefined" && Boolean(process.stdout && process.stdout.isTTY);
100154
100154
  };
100155
+ var isSilent = () => {
100156
+ return typeof process !== "undefined" && process.env.LOG_SILENT === "true";
100157
+ };
100155
100158
  var detectOutputFormat = () => {
100156
100159
  if (isBrowser()) {
100157
100160
  return "browser";
@@ -100259,6 +100262,8 @@ var getMinimumLogLevel = () => {
100259
100262
  return isProduction() ? "info" : "debug";
100260
100263
  };
100261
100264
  var shouldLog = (level) => {
100265
+ if (isSilent())
100266
+ return false;
100262
100267
  const minLevel = getMinimumLogLevel();
100263
100268
  return levelPriority[level] >= levelPriority[minLevel];
100264
100269
  };
@@ -160042,7 +160047,7 @@ var logger2 = (fn = console.log) => {
160042
160047
  };
160043
160048
  var package_default = {
160044
160049
  name: "@playcademy/sandbox",
160045
- version: "0.1.7",
160050
+ version: "0.1.8",
160046
160051
  description: "Local development server for Playcademy game development",
160047
160052
  type: "module",
160048
160053
  exports: {
@@ -166524,6 +166529,9 @@ var isDevelopment2 = () => {
166524
166529
  var isInteractiveTTY2 = () => {
166525
166530
  return typeof process !== "undefined" && Boolean(process.stdout && process.stdout.isTTY);
166526
166531
  };
166532
+ var isSilent2 = () => {
166533
+ return typeof process !== "undefined" && process.env.LOG_SILENT === "true";
166534
+ };
166527
166535
  var detectOutputFormat2 = () => {
166528
166536
  if (isBrowser2()) {
166529
166537
  return "browser";
@@ -166644,6 +166652,8 @@ var getMinimumLogLevel2 = () => {
166644
166652
  return isProduction2() ? "info" : "debug";
166645
166653
  };
166646
166654
  var shouldLog2 = (level) => {
166655
+ if (isSilent2())
166656
+ return false;
166647
166657
  const minLevel = getMinimumLogLevel2();
166648
166658
  return levelPriority2[level] >= levelPriority2[minLevel];
166649
166659
  };
@@ -205378,7 +205388,7 @@ var shell_no_badge_default = `<!doctype html>
205378
205388
  ></div>
205379
205389
  </div>
205380
205390
 
205381
- <iframe class="game-frame hidden" id="gameFrame" src="/game"></iframe>
205391
+ <iframe class="game-frame hidden" id="gameFrame" src="/"></iframe>
205382
205392
  </div>
205383
205393
 
205384
205394
  <script type="module">
@@ -205479,7 +205489,7 @@ var shell_no_badge_default = `<!doctype html>
205479
205489
  stopHandshake()
205480
205490
  })
205481
205491
 
205482
- gameFrame.src = '/game'
205492
+ gameFrame.src = '/'
205483
205493
  }
205484
205494
 
205485
205495
  window.addEventListener('message', event => {
@@ -205608,7 +205618,7 @@ var shell_with_corner_badge_default = `<!doctype html>
205608
205618
  ></div>
205609
205619
  </div>
205610
205620
 
205611
- <iframe class="game-frame hidden" id="gameFrame" src="/game"></iframe>
205621
+ <iframe class="game-frame hidden" id="gameFrame" src="/"></iframe>
205612
205622
  </div>
205613
205623
 
205614
205624
  <script type="module">
@@ -205714,7 +205724,7 @@ var shell_with_corner_badge_default = `<!doctype html>
205714
205724
  stopHandshake()
205715
205725
  })
205716
205726
 
205717
- gameFrame.src = '/game'
205727
+ gameFrame.src = '/'
205718
205728
  }
205719
205729
 
205720
205730
  window.addEventListener('message', event => {
@@ -205748,14 +205758,14 @@ function generateLoaderHTML(sandboxUrl, gameId, realtimeUrl, showBadge, gameUrl)
205748
205758
  function devServerMiddleware(server, sandbox, gameUrl, showBadge) {
205749
205759
  server.middlewares.use("/", (req, res, next) => {
205750
205760
  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();
205761
+ const secFetchDest = req.headers["sec-fetch-dest"];
205762
+ if (secFetchDest === "iframe") {
205763
+ next();
205764
+ } else {
205765
+ res.setHeader("Content-Type", "text/html");
205766
+ const gameId = sandbox.project?.slug;
205767
+ res.end(generateLoaderHTML(sandbox.baseUrl, gameId ?? "", sandbox.realtimeUrl, showBadge, gameUrl));
205768
+ }
205759
205769
  return;
205760
205770
  }
205761
205771
  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.22",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -25,11 +25,11 @@
25
25
  "dependencies": {
26
26
  "archiver": "^7.0.1",
27
27
  "picocolors": "^1.1.1",
28
- "playcademy": "0.13.21"
28
+ "playcademy": "0.13.23"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@inquirer/prompts": "^7.8.6",
32
- "@playcademy/sandbox": "0.1.7",
32
+ "@playcademy/sandbox": "0.1.8",
33
33
  "@types/archiver": "^6.0.3",
34
34
  "@types/bun": "latest",
35
35
  "yocto-spinner": "^0.2.2"