@playcademy/vite-plugin 0.2.2 → 0.2.4
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 +12 -12
- package/dist/index.js +54 -54
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @playcademy/vite-plugin
|
|
2
2
|
|
|
3
|
-
**Vite plugin for Playcademy
|
|
3
|
+
**Vite plugin for Playcademy app development and deployment**
|
|
4
4
|
|
|
5
5
|
This plugin integrates Playcademy's development sandbox and build tools into your Vite workflow, automatically generating manifests, managing development environments, and creating deployment-ready archives.
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
The Playcademy Vite plugin streamlines
|
|
9
|
+
The Playcademy Vite plugin streamlines app development by providing:
|
|
10
10
|
|
|
11
11
|
- **Development Sandbox**: Automatically starts a local Playcademy API server during development.
|
|
12
12
|
- **Manifest Generation**: Creates required `playcademy.manifest.json` files for platform deployment
|
|
@@ -23,7 +23,7 @@ The Playcademy Vite plugin streamlines game development by providing:
|
|
|
23
23
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
26
|
-
Install the plugin in your Playcademy
|
|
26
|
+
Install the plugin in your Playcademy project:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
# Using Bun (recommended)
|
|
@@ -64,7 +64,7 @@ bun dev
|
|
|
64
64
|
The plugin will:
|
|
65
65
|
|
|
66
66
|
- Start the sandbox server at `http://localhost:4321/api`
|
|
67
|
-
- Enable API integration for your
|
|
67
|
+
- Enable API integration for your app
|
|
68
68
|
- Provide hot reload for rapid development
|
|
69
69
|
|
|
70
70
|
## Configuration
|
|
@@ -260,9 +260,9 @@ During development, the plugin provides keyboard shortcuts in the terminal:
|
|
|
260
260
|
During `bun dev`, the plugin:
|
|
261
261
|
|
|
262
262
|
- Starts the sandbox server (if enabled)
|
|
263
|
-
- Provides
|
|
264
|
-
- Enables hot reload for
|
|
265
|
-
- Seamlessly wraps your
|
|
263
|
+
- Provides API simulation
|
|
264
|
+
- Enables hot reload for your code
|
|
265
|
+
- Seamlessly wraps your app in the Playcademy environment
|
|
266
266
|
|
|
267
267
|
Console output:
|
|
268
268
|
|
|
@@ -274,15 +274,15 @@ VITE v6.3.5 ready in 500ms
|
|
|
274
274
|
|
|
275
275
|
PLAYCADEMY v1.2.3
|
|
276
276
|
|
|
277
|
-
➜
|
|
277
|
+
➜ Project: my-app
|
|
278
278
|
➜ Sandbox: http://localhost:4321/api
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
**How it works**: When you visit `http://localhost:5173/` in your browser, you'll see your
|
|
281
|
+
**How it works**: When you visit `http://localhost:5173/` in your browser, you'll see your app wrapped in the Playcademy development shell (which mimics the production platform environment). Inside the iframe, your app is served at the root path `/`, so client-side routers (React Router, wouter, etc.) work naturally without any special configuration.
|
|
282
282
|
|
|
283
283
|
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.
|
|
284
284
|
|
|
285
|
-
**Client-side routing**: Both in development and production, your routers will see clean paths like `/` and `/game`. In production, the platform uses a
|
|
285
|
+
**Client-side routing**: Both in development and production, your routers will see clean paths like `/` and `/game`. In production, the platform uses a runner that loads your app from the CDN while presenting clean routing paths. You don't need to configure anything - just write your routes normally:
|
|
286
286
|
|
|
287
287
|
```tsx
|
|
288
288
|
<Router>
|
|
@@ -292,7 +292,7 @@ The plugin uses the `Sec-Fetch-Dest` header to intelligently detect whether a re
|
|
|
292
292
|
</Router>
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
**Runtime asset loading**: If your
|
|
295
|
+
**Runtime asset loading**: If your app loads assets dynamically at runtime (files that Vite can't analyze at build time), use the SDK's CDN helpers:
|
|
296
296
|
|
|
297
297
|
```typescript
|
|
298
298
|
import { PlaycademyClient } from '@playcademy/sdk'
|
|
@@ -399,7 +399,7 @@ bun run pub
|
|
|
399
399
|
|
|
400
400
|
## Common Use Cases
|
|
401
401
|
|
|
402
|
-
### Basic Web
|
|
402
|
+
### Basic Web App
|
|
403
403
|
|
|
404
404
|
```typescript
|
|
405
405
|
// Minimal configuration for most web games
|
package/dist/index.js
CHANGED
|
@@ -186453,6 +186453,55 @@ async function verifyGameAccessBySlug(slug2, user) {
|
|
|
186453
186453
|
function getGameWorkerApiKeyName(slug2) {
|
|
186454
186454
|
return `game-worker-${slug2}`.substring(0, 32);
|
|
186455
186455
|
}
|
|
186456
|
+
var import_client_s32 = __toESM2(require_dist_cjs81(), 1);
|
|
186457
|
+
function getSecretsConfig() {
|
|
186458
|
+
const bucketName = process.env.GAME_SECRETS_BUCKET;
|
|
186459
|
+
const masterKey = process.env.GAME_SECRETS_MASTER_KEY;
|
|
186460
|
+
if (!bucketName || !masterKey) {
|
|
186461
|
+
throw new Error("Secrets storage not configured");
|
|
186462
|
+
}
|
|
186463
|
+
const accessKeyId = process.env.CLOUDFLARE_R2_ACCESS_KEY_ID;
|
|
186464
|
+
const secretAccessKey = process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY;
|
|
186465
|
+
const endpoint = process.env.CLOUDFLARE_R2_DEFAULT_ENDPOINT;
|
|
186466
|
+
if (!accessKeyId || !secretAccessKey || !endpoint) {
|
|
186467
|
+
throw new Error("R2 credentials not configured");
|
|
186468
|
+
}
|
|
186469
|
+
return {
|
|
186470
|
+
bucketName,
|
|
186471
|
+
credentials: {
|
|
186472
|
+
accessKeyId,
|
|
186473
|
+
secretAccessKey,
|
|
186474
|
+
endpoint
|
|
186475
|
+
},
|
|
186476
|
+
masterKey
|
|
186477
|
+
};
|
|
186478
|
+
}
|
|
186479
|
+
function getSecretsKey(gameId) {
|
|
186480
|
+
return `${gameId}.json.enc`;
|
|
186481
|
+
}
|
|
186482
|
+
function createR2Client(config2) {
|
|
186483
|
+
return new import_client_s32.S3Client({
|
|
186484
|
+
region: "auto",
|
|
186485
|
+
endpoint: config2.credentials.endpoint,
|
|
186486
|
+
credentials: {
|
|
186487
|
+
accessKeyId: config2.credentials.accessKeyId,
|
|
186488
|
+
secretAccessKey: config2.credentials.secretAccessKey
|
|
186489
|
+
}
|
|
186490
|
+
});
|
|
186491
|
+
}
|
|
186492
|
+
async function deleteSecrets(gameId, config2) {
|
|
186493
|
+
const client = createR2Client(config2);
|
|
186494
|
+
const key = getSecretsKey(gameId);
|
|
186495
|
+
try {
|
|
186496
|
+
await client.send(new import_client_s32.DeleteObjectCommand({
|
|
186497
|
+
Bucket: config2.bucketName,
|
|
186498
|
+
Key: key
|
|
186499
|
+
}));
|
|
186500
|
+
} catch (error2) {
|
|
186501
|
+
log2.error("[SecretsStorage] Failed to delete secrets", { gameId, error: error2 });
|
|
186502
|
+
throw new Error(`Failed to delete secrets for game ${gameId}`);
|
|
186503
|
+
}
|
|
186504
|
+
}
|
|
186456
186505
|
async function seedAchievements(db) {
|
|
186457
186506
|
const now2 = new Date;
|
|
186458
186507
|
for (const def of ACHIEVEMENT_DEFINITIONS) {
|
|
@@ -192214,55 +192263,6 @@ usersRouter.all("/", async (c3) => {
|
|
|
192214
192263
|
const error2 = ApiError.methodNotAllowed("Method not allowed");
|
|
192215
192264
|
return c3.json(createErrorResponse(error2), 405);
|
|
192216
192265
|
});
|
|
192217
|
-
var import_client_s32 = __toESM2(require_dist_cjs81(), 1);
|
|
192218
|
-
function getSecretsConfig() {
|
|
192219
|
-
const bucketName = process.env.GAME_SECRETS_BUCKET;
|
|
192220
|
-
const masterKey = process.env.GAME_SECRETS_MASTER_KEY;
|
|
192221
|
-
if (!bucketName || !masterKey) {
|
|
192222
|
-
throw new Error("Secrets storage not configured");
|
|
192223
|
-
}
|
|
192224
|
-
const accessKeyId = process.env.CLOUDFLARE_R2_ACCESS_KEY_ID;
|
|
192225
|
-
const secretAccessKey = process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY;
|
|
192226
|
-
const endpoint = process.env.CLOUDFLARE_R2_DEFAULT_ENDPOINT;
|
|
192227
|
-
if (!accessKeyId || !secretAccessKey || !endpoint) {
|
|
192228
|
-
throw new Error("R2 credentials not configured");
|
|
192229
|
-
}
|
|
192230
|
-
return {
|
|
192231
|
-
bucketName,
|
|
192232
|
-
credentials: {
|
|
192233
|
-
accessKeyId,
|
|
192234
|
-
secretAccessKey,
|
|
192235
|
-
endpoint
|
|
192236
|
-
},
|
|
192237
|
-
masterKey
|
|
192238
|
-
};
|
|
192239
|
-
}
|
|
192240
|
-
function getSecretsKey(gameId) {
|
|
192241
|
-
return `${gameId}.json.enc`;
|
|
192242
|
-
}
|
|
192243
|
-
function createR2Client(config2) {
|
|
192244
|
-
return new import_client_s32.S3Client({
|
|
192245
|
-
region: "auto",
|
|
192246
|
-
endpoint: config2.credentials.endpoint,
|
|
192247
|
-
credentials: {
|
|
192248
|
-
accessKeyId: config2.credentials.accessKeyId,
|
|
192249
|
-
secretAccessKey: config2.credentials.secretAccessKey
|
|
192250
|
-
}
|
|
192251
|
-
});
|
|
192252
|
-
}
|
|
192253
|
-
async function deleteSecrets(gameId, config2) {
|
|
192254
|
-
const client = createR2Client(config2);
|
|
192255
|
-
const key = getSecretsKey(gameId);
|
|
192256
|
-
try {
|
|
192257
|
-
await client.send(new import_client_s32.DeleteObjectCommand({
|
|
192258
|
-
Bucket: config2.bucketName,
|
|
192259
|
-
Key: key
|
|
192260
|
-
}));
|
|
192261
|
-
} catch (error2) {
|
|
192262
|
-
log2.error("[SecretsStorage] Failed to delete secrets", { gameId, error: error2 });
|
|
192263
|
-
throw new Error(`Failed to delete secrets for game ${gameId}`);
|
|
192264
|
-
}
|
|
192265
|
-
}
|
|
192266
192266
|
function assertError(err2) {
|
|
192267
192267
|
if (!isError(err2)) {
|
|
192268
192268
|
throw new Error("Parameter was not an error");
|
|
@@ -198086,7 +198086,7 @@ function printBanner(viteConfig, options) {
|
|
|
198086
198086
|
viteConfig.logger.info(`${INDENT}${import_picocolors3.green(import_picocolors3.bold("PLAYCADEMY"))} ${import_picocolors3.green(`v${version4}`)}`);
|
|
198087
198087
|
viteConfig.logger.info("");
|
|
198088
198088
|
if (gameName) {
|
|
198089
|
-
viteConfig.logger.info(`${INDENT}${import_picocolors3.green("➜")} ${import_picocolors3.bold("
|
|
198089
|
+
viteConfig.logger.info(`${INDENT}${import_picocolors3.green("➜")} ${import_picocolors3.bold("Project:")} ${import_picocolors3.cyan(gameName)}`);
|
|
198090
198090
|
}
|
|
198091
198091
|
if (sandbox?.enabled) {
|
|
198092
198092
|
viteConfig.logger.info(`${INDENT}${import_picocolors3.green("➜")} ${import_picocolors3.bold("Sandbox:")} ${import_picocolors3.cyan(`http://localhost:${import_picocolors3.bold(sandbox.port.toString())}/api`)}`);
|
|
@@ -198908,12 +198908,12 @@ var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
|
198908
198908
|
// package.json
|
|
198909
198909
|
var package_default2 = {
|
|
198910
198910
|
name: "@playcademy/vite-plugin",
|
|
198911
|
-
version: "0.2.
|
|
198911
|
+
version: "0.2.4",
|
|
198912
198912
|
type: "module",
|
|
198913
198913
|
exports: {
|
|
198914
198914
|
".": {
|
|
198915
|
-
|
|
198916
|
-
|
|
198915
|
+
types: "./dist/index.d.ts",
|
|
198916
|
+
import: "./dist/index.js"
|
|
198917
198917
|
}
|
|
198918
198918
|
},
|
|
198919
198919
|
main: "dist/index.js",
|
|
@@ -198927,7 +198927,6 @@ var package_default2 = {
|
|
|
198927
198927
|
pub: "bun publish.ts"
|
|
198928
198928
|
},
|
|
198929
198929
|
dependencies: {
|
|
198930
|
-
"@playcademy/utils": "workspace:*",
|
|
198931
198930
|
archiver: "^7.0.1",
|
|
198932
198931
|
picocolors: "^1.1.1",
|
|
198933
198932
|
playcademy: "workspace:*"
|
|
@@ -198935,6 +198934,7 @@ var package_default2 = {
|
|
|
198935
198934
|
devDependencies: {
|
|
198936
198935
|
"@inquirer/prompts": "^7.8.6",
|
|
198937
198936
|
"@playcademy/sandbox": "workspace:*",
|
|
198937
|
+
"@playcademy/utils": "workspace:*",
|
|
198938
198938
|
"@types/archiver": "^6.0.3",
|
|
198939
198939
|
"@types/bun": "latest"
|
|
198940
198940
|
},
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/index.js",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"pub": "bun publish.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@playcademy/utils": "0.0.1",
|
|
23
22
|
"archiver": "^7.0.1",
|
|
24
23
|
"picocolors": "^1.1.1",
|
|
25
|
-
"playcademy": "0.14.
|
|
24
|
+
"playcademy": "0.14.30"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@inquirer/prompts": "^7.8.6",
|
|
29
28
|
"@playcademy/sandbox": "0.3.6",
|
|
29
|
+
"@playcademy/utils": "0.0.1",
|
|
30
30
|
"@types/archiver": "^6.0.3",
|
|
31
31
|
"@types/bun": "latest"
|
|
32
32
|
},
|