@playcademy/vite-plugin 0.0.1-beta.25 → 0.0.1-beta.27

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 (2) hide show
  1. package/dist/index.js +26 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -97729,7 +97729,7 @@ var logger = (fn = console.log) => {
97729
97729
  };
97730
97730
  var package_default = {
97731
97731
  name: "@playcademy/sandbox",
97732
- version: "0.1.0-beta.17",
97732
+ version: "0.1.0-beta.18",
97733
97733
  description: "Local development server for Playcademy game development",
97734
97734
  type: "module",
97735
97735
  exports: {
@@ -110955,9 +110955,10 @@ async function createSandboxRealtimeServer(options = {}) {
110955
110955
  removeConnection();
110956
110956
  });
110957
110957
  ws.on("message", (data) => {
110958
+ const text5 = typeof data === "string" ? data : data.toString("utf8");
110958
110959
  wss.clients.forEach((client2) => {
110959
110960
  if (client2.readyState === import_websocket.default.OPEN) {
110960
- client2.send(data);
110961
+ client2.send(text5);
110961
110962
  }
110962
110963
  });
110963
110964
  });
@@ -118032,6 +118033,28 @@ async function generateRealtimeToken(ctx) {
118032
118033
  throw ApiError.internal("Internal server error", error2);
118033
118034
  }
118034
118035
  }
118036
+ async function generateSandboxRealtimeToken(ctx) {
118037
+ const gameIdOrSlug = ctx.params?.gameId;
118038
+ const db = getDatabase();
118039
+ let resolvedGameId = gameIdOrSlug;
118040
+ if (gameIdOrSlug && db) {
118041
+ const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(gameIdOrSlug);
118042
+ if (!isUuid) {
118043
+ const game = await db.query.games.findFirst({
118044
+ where: eq(games.slug, gameIdOrSlug),
118045
+ columns: { id: true }
118046
+ });
118047
+ if (game) {
118048
+ resolvedGameId = game.id;
118049
+ }
118050
+ }
118051
+ }
118052
+ const newCtx = {
118053
+ ...ctx,
118054
+ params: { ...ctx.params, gameId: resolvedGameId }
118055
+ };
118056
+ return generateRealtimeToken(newCtx);
118057
+ }
118035
118058
 
118036
118059
  class BigEndian {
118037
118060
  uint8(data, offset) {
@@ -119002,7 +119025,7 @@ gamesRouter.post("/:gameId/realtime/token", async (c2) => {
119002
119025
  request: c2.req.raw
119003
119026
  };
119004
119027
  try {
119005
- const result = await generateRealtimeToken(ctx);
119028
+ const result = await generateSandboxRealtimeToken(ctx);
119006
119029
  return c2.json(result);
119007
119030
  } catch (error2) {
119008
119031
  if (error2 instanceof ApiError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/vite-plugin",
3
- "version": "0.0.1-beta.25",
3
+ "version": "0.0.1-beta.27",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {