@playcademy/vite-plugin 0.1.26-alpha.1 → 0.1.26-alpha.3

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 CHANGED
@@ -79,7 +79,7 @@ export default defineConfig({
79
79
  playcademy({
80
80
  export: {
81
81
  platform: 'web', // Platform identifier (auto-detected)
82
- autoZip: false, // Create deployment zip
82
+ autoZip: true, // Create deployment zip (enabled by default)
83
83
  },
84
84
  sandbox: {
85
85
  autoStart: true, // Start sandbox automatically
@@ -95,14 +95,16 @@ export default defineConfig({
95
95
  })
96
96
  ```
97
97
 
98
- ### Production Build Configuration
98
+ ### Disabling Auto-Zip
99
+
100
+ By default, the plugin creates a deployment archive. To disable:
99
101
 
100
102
  ```typescript
101
103
  export default defineConfig({
102
104
  plugins: [
103
105
  playcademy({
104
106
  export: {
105
- autoZip: true, // Creates .playcademy/{project-name}.zip
107
+ autoZip: false, // Disable automatic zip creation
106
108
  },
107
109
  }),
108
110
  ],
@@ -134,7 +136,7 @@ Configuration for manifest generation and build output:
134
136
  | Option | Type | Default | Description |
135
137
  | ---------- | --------- | ------- | ---------------------------------------------- |
136
138
  | `platform` | `string` | `'web'` | Platform identifier (e.g., 'web', 'godot@4.3') |
137
- | `autoZip` | `boolean` | `false` | Create deployment zip archive |
139
+ | `autoZip` | `boolean` | `true` | Create deployment zip archive |
138
140
 
139
141
  ### Sandbox Options (`sandbox`)
140
142
 
@@ -243,7 +245,7 @@ The plugin generates `dist/playcademy.manifest.json`:
243
245
 
244
246
  ### Deployment Archive
245
247
 
246
- With `autoZip: true`, creates `.playcademy/{project-name}.zip` containing all build files ready for platform upload.
248
+ By default, the plugin creates `.playcademy/{project-name}.zip` containing all build files ready for platform upload. This can be disabled by setting `autoZip: false`.
247
249
 
248
250
  ## Development
249
251
 
@@ -335,16 +337,13 @@ export default defineConfig({
335
337
  })
336
338
  ```
337
339
 
338
- ### Production Deployment
340
+ ### Mode-Based Configuration
339
341
 
340
342
  ```typescript
341
- // Optimized for production builds
343
+ // Different settings for development vs production
342
344
  export default defineConfig(({ mode }) => ({
343
345
  plugins: [
344
346
  playcademy({
345
- export: {
346
- autoZip: mode === 'production',
347
- },
348
347
  sandbox: {
349
348
  verbose: mode === 'development',
350
349
  },
@@ -365,9 +364,9 @@ export default defineConfig(({ mode }) => ({
365
364
 
366
365
  **Zip file not created**
367
366
 
368
- - Enable `autoZip: true` in export options
369
- - Check that build completed without errors
367
+ - Auto-zip is enabled by default - check that build completed without errors
370
368
  - Look for zip in `.playcademy/` directory
369
+ - If you previously disabled it, remove `autoZip: false` from export options
371
370
 
372
371
  ### Debug Mode
373
372
 
package/dist/index.js CHANGED
@@ -41138,11 +41138,25 @@ import { DEFAULT_PORTS as DEFAULT_PORTS3 } from "playcademy/constants";
41138
41138
  // src/server/state.ts
41139
41139
  var serverState = {
41140
41140
  sandbox: null,
41141
- backend: null
41141
+ backend: null,
41142
+ viteServer: null,
41143
+ currentMode: "platform"
41142
41144
  };
41143
41145
  function hasActiveServers() {
41144
41146
  return !!(serverState.backend || serverState.sandbox);
41145
41147
  }
41148
+ function getCurrentMode() {
41149
+ return serverState.currentMode;
41150
+ }
41151
+ function setCurrentMode(mode) {
41152
+ serverState.currentMode = mode;
41153
+ }
41154
+ function getViteServerRef() {
41155
+ return serverState.viteServer;
41156
+ }
41157
+ function setViteServerRef(server) {
41158
+ serverState.viteServer = server;
41159
+ }
41146
41160
 
41147
41161
  // src/server/cleanup.ts
41148
41162
  async function cleanupServers() {
@@ -41179,10 +41193,13 @@ function setupProcessShutdownHandlers() {
41179
41193
  process.on("SIGINT", shutdown);
41180
41194
  process.on("SIGTERM", shutdown);
41181
41195
  }
41196
+
41197
+ // src/server/mode-switcher.ts
41198
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
41182
41199
  // package.json
41183
41200
  var package_default = {
41184
41201
  name: "@playcademy/vite-plugin",
41185
- version: "0.1.25",
41202
+ version: "0.1.26",
41186
41203
  type: "module",
41187
41204
  exports: {
41188
41205
  ".": {
@@ -41197,8 +41214,8 @@ var package_default = {
41197
41214
  ],
41198
41215
  scripts: {
41199
41216
  build: "rm -rf dist && bun build.ts",
41200
- pub: "bun publish.ts",
41201
- docs: "typedoc --skipErrorChecking"
41217
+ docs: "typedoc --skipErrorChecking",
41218
+ pub: "bun publish.ts"
41202
41219
  },
41203
41220
  dependencies: {
41204
41221
  archiver: "^7.0.1",
@@ -205912,6 +205929,10 @@ function generateLoaderHTML(sandboxUrl, gameId, realtimeUrl, showBadge, gameUrl)
205912
205929
  }
205913
205930
  function devServerMiddleware(server, sandbox, gameUrl, showBadge) {
205914
205931
  server.middlewares.use("/", (req, res, next) => {
205932
+ if (getCurrentMode() !== "platform") {
205933
+ next();
205934
+ return;
205935
+ }
205915
205936
  if (req.url === "/" && req.method === "GET") {
205916
205937
  const secFetchDest = req.headers["sec-fetch-dest"];
205917
205938
  if (secFetchDest === "iframe") {
@@ -205979,28 +206000,77 @@ async function configureStandaloneMode(server, viteConfig, preferredPort) {
205979
206000
  });
205980
206001
  }
205981
206002
 
206003
+ // src/server/mode-switcher.ts
206004
+ async function toggleMode(options) {
206005
+ const currentMode = getCurrentMode();
206006
+ const newMode = currentMode === "platform" ? "standalone" : "platform";
206007
+ const viteServer = getViteServerRef();
206008
+ if (!viteServer) {
206009
+ options.viteConfig.logger.error("[Playcademy] Cannot toggle mode: no Vite server reference");
206010
+ return;
206011
+ }
206012
+ options.viteConfig.logger.info("");
206013
+ options.viteConfig.logger.info(import_picocolors7.default.yellow(`Switching from ${import_picocolors7.default.bold(currentMode)} to ${import_picocolors7.default.bold(newMode)} mode...`));
206014
+ options.viteConfig.logger.info("");
206015
+ await cleanupServers();
206016
+ await new Promise((resolve2) => setTimeout(resolve2, 100));
206017
+ setCurrentMode(newMode);
206018
+ if (newMode === "standalone") {
206019
+ await configureStandaloneMode(viteServer, options.viteConfig, options.platformModeOptions.preferredBackendPort);
206020
+ } else {
206021
+ await configurePlatformMode(viteServer, options.viteConfig, options.platformModeOptions);
206022
+ }
206023
+ options.viteConfig.logger.info("");
206024
+ options.viteConfig.logger.info(import_picocolors7.default.green(`✓ Switched to ${import_picocolors7.default.bold(newMode)} mode`));
206025
+ options.viteConfig.logger.info("");
206026
+ }
206027
+
205982
206028
  // src/hooks/configure-server.ts
205983
206029
  async function configureServerHook(server, context) {
205984
206030
  if (!context.viteConfig) {
205985
206031
  throw new Error("[Playcademy] Vite config not resolved before configureServer");
205986
206032
  }
206033
+ setViteServerRef(server);
206034
+ setCurrentMode(context.options.mode);
205987
206035
  setupProcessShutdownHandlers();
205988
206036
  if (hasActiveServers()) {
205989
206037
  await cleanupServers();
205990
206038
  await new Promise((resolve2) => setTimeout(resolve2, 100));
205991
206039
  }
205992
206040
  const preferredPort = context.backendPort ?? DEFAULT_PORTS3.BACKEND;
206041
+ const platformModeOptions = {
206042
+ startSandbox: context.options.startSandbox,
206043
+ verbose: context.options.verbose,
206044
+ sandboxUrl: context.options.sandboxUrl,
206045
+ recreateDb: context.options.recreateDb,
206046
+ showBadge: context.options.showBadge,
206047
+ preferredBackendPort: preferredPort
206048
+ };
205993
206049
  if (context.options.mode === "standalone") {
205994
206050
  await configureStandaloneMode(server, context.viteConfig, preferredPort);
205995
206051
  } else {
205996
- await configurePlatformMode(server, context.viteConfig, {
205997
- startSandbox: context.options.startSandbox,
205998
- verbose: context.options.verbose,
205999
- sandboxUrl: context.options.sandboxUrl,
206000
- recreateDb: context.options.recreateDb,
206001
- showBadge: context.options.showBadge,
206002
- preferredBackendPort: preferredPort
206003
- });
206052
+ await configurePlatformMode(server, context.viteConfig, platformModeOptions);
206053
+ }
206054
+ const originalBindCLIShortcuts = server.bindCLIShortcuts?.bind(server);
206055
+ if (originalBindCLIShortcuts) {
206056
+ server.bindCLIShortcuts = (options) => {
206057
+ originalBindCLIShortcuts({
206058
+ ...options,
206059
+ customShortcuts: [
206060
+ ...options?.customShortcuts || [],
206061
+ {
206062
+ key: "m",
206063
+ description: "toggle platform/standalone mode",
206064
+ action: async () => {
206065
+ await toggleMode({
206066
+ viteConfig: context.viteConfig,
206067
+ platformModeOptions
206068
+ });
206069
+ }
206070
+ }
206071
+ ]
206072
+ });
206073
+ };
206004
206074
  }
206005
206075
  }
206006
206076
 
@@ -206032,7 +206102,7 @@ function resolveOptions(options) {
206032
206102
  const shellOptions = options.shell ?? {};
206033
206103
  return {
206034
206104
  mode: options.mode ?? "platform",
206035
- autoZip: exportOptions.autoZip ?? false,
206105
+ autoZip: exportOptions.autoZip ?? true,
206036
206106
  sandboxUrl: sandboxOptions.url ?? `http://localhost:${DEFAULT_PORTS4.SANDBOX}`,
206037
206107
  startSandbox: sandboxOptions.url ? false : sandboxOptions.autoStart ?? true,
206038
206108
  verbose: sandboxOptions.verbose ?? false,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Mode switching functionality
3
+ * Handles toggling between platform and standalone modes
4
+ */
5
+ import type { ResolvedConfig } from 'vite';
6
+ import type { PlatformModeOptions } from './platform-mode';
7
+ export interface ModeSwitcherOptions {
8
+ viteConfig: ResolvedConfig;
9
+ platformModeOptions: PlatformModeOptions;
10
+ }
11
+ /**
12
+ * Toggle between platform and standalone modes
13
+ */
14
+ export declare function toggleMode(options: ModeSwitcherOptions): Promise<void>;
@@ -6,13 +6,17 @@
6
6
  * but the servers continue running in the same Node process. We maintain
7
7
  * these references at module scope to properly clean them up on restart.
8
8
  */
9
+ import type { ViteDevServer } from 'vite';
9
10
  import type { CliServerManager, SandboxManager } from '../types';
11
+ import type { PlaycademyMode } from '../types/options';
10
12
  /**
11
13
  * Module-level server references
12
14
  */
13
15
  export declare const serverState: {
14
16
  sandbox: SandboxManager | null;
15
17
  backend: CliServerManager | null;
18
+ viteServer: ViteDevServer | null;
19
+ currentMode: PlaycademyMode;
16
20
  };
17
21
  /**
18
22
  * Get sandbox server reference
@@ -34,3 +38,19 @@ export declare function setBackendRef(backend: CliServerManager | null): void;
34
38
  * Check if any servers are currently running
35
39
  */
36
40
  export declare function hasActiveServers(): boolean;
41
+ /**
42
+ * Get current mode
43
+ */
44
+ export declare function getCurrentMode(): PlaycademyMode;
45
+ /**
46
+ * Set current mode
47
+ */
48
+ export declare function setCurrentMode(mode: PlaycademyMode): void;
49
+ /**
50
+ * Get Vite dev server reference
51
+ */
52
+ export declare function getViteServerRef(): ViteDevServer | null;
53
+ /**
54
+ * Set Vite dev server reference
55
+ */
56
+ export declare function setViteServerRef(server: ViteDevServer | null): void;
@@ -11,6 +11,10 @@ export type PlaycademyMode = 'platform' | 'standalone';
11
11
  * Configuration options for exporting Playcademy games
12
12
  */
13
13
  export interface PlaycademyExportOptions {
14
+ /**
15
+ * Automatically create a deployment zip archive at .playcademy/{project-name}.zip
16
+ * @default true
17
+ */
14
18
  autoZip?: boolean;
15
19
  }
16
20
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/vite-plugin",
3
- "version": "0.1.26-alpha.1",
3
+ "version": "0.1.26-alpha.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -15,13 +15,13 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "rm -rf dist && bun build.ts",
18
- "pub": "bun publish.ts",
19
- "docs": "typedoc --skipErrorChecking"
18
+ "docs": "typedoc --skipErrorChecking",
19
+ "pub": "bun publish.ts"
20
20
  },
21
21
  "dependencies": {
22
22
  "archiver": "^7.0.1",
23
23
  "picocolors": "^1.1.1",
24
- "playcademy": "0.14.3"
24
+ "playcademy": "0.14.4"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@inquirer/prompts": "^7.8.6",