@playcademy/vite-plugin 0.1.40 → 0.2.1
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 +75 -46
- package/dist/index.js +6387 -19249
- package/dist/lib/logging/adapter.d.ts +2 -2
- package/dist/lib/logging/index.d.ts +2 -2
- package/dist/lib/logging/utils.d.ts +11 -10
- package/dist/lib/sandbox/index.d.ts +1 -1
- package/dist/lib/sandbox/project-info.d.ts +1 -2
- package/dist/lib/sandbox/server.d.ts +3 -7
- package/dist/lib/sandbox/timeback.d.ts +31 -6
- package/dist/lib/sandbox/token.d.ts +25 -0
- package/dist/server/config-watcher.d.ts +15 -0
- package/dist/server/hotkeys/cycle-platform-role.d.ts +9 -0
- package/dist/server/middleware.d.ts +3 -4
- package/dist/server/recreate-sandbox.d.ts +21 -0
- package/dist/server/state.d.ts +10 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/internal.d.ts +58 -14
- package/dist/types/options.d.ts +61 -64
- package/package.json +4 -3
|
@@ -14,6 +14,6 @@ export interface PluginLogger {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Creates a logger adapter that formats logs in Vite's style with [playcademy] prefix
|
|
17
|
-
* @param
|
|
17
|
+
* @param domain - Domain to add to all logs (e.g., 'backend', 'sandbox')
|
|
18
18
|
*/
|
|
19
|
-
export declare function createLoggerAdapter(
|
|
19
|
+
export declare function createLoggerAdapter(domain: string): PluginLogger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Logging utilities
|
|
3
3
|
*/
|
|
4
|
-
export { createLoggerAdapter } from './adapter';
|
|
5
4
|
export type { PluginLogger } from './adapter';
|
|
6
|
-
export {
|
|
5
|
+
export { createLoggerAdapter } from './adapter';
|
|
6
|
+
export { createBackendBannerOptions, createTimebackBannerOptions, log, printBanner } from './utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResolvedConfig } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BannerOptions } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Centralized logging utilities for the Vite plugin.
|
|
5
5
|
* Provides clear, prefixed, and color-coded output for multiple servers.
|
|
@@ -9,17 +9,18 @@ export declare const log: {
|
|
|
9
9
|
backend: (msg: string) => void;
|
|
10
10
|
playcademy: (msg: string) => void;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Create backend banner options from server info
|
|
14
|
+
*/
|
|
15
|
+
export declare function createBackendBannerOptions(backendPort: number | undefined, vitePort: number | undefined): BannerOptions['backend'];
|
|
16
|
+
/**
|
|
17
|
+
* Create timeback banner options from sandbox state
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTimebackBannerOptions(timebackMode: 'mock' | 'remote' | 'local' | null | undefined, courseCount: number | undefined, enrolledCount?: number): BannerOptions['timeback'];
|
|
12
20
|
/**
|
|
13
21
|
* Prints a startup banner showing all running servers in Vite's style.
|
|
14
22
|
*
|
|
15
23
|
* @param viteConfig - Vite resolved configuration
|
|
16
|
-
* @param
|
|
17
|
-
* @param projectInfo - Project information
|
|
18
|
-
* @param pluginVersion - Vite plugin version string
|
|
24
|
+
* @param options - Banner display options
|
|
19
25
|
*/
|
|
20
|
-
export declare function printBanner(viteConfig: ResolvedConfig,
|
|
21
|
-
sandbox: number;
|
|
22
|
-
backend?: number;
|
|
23
|
-
realtime?: number;
|
|
24
|
-
vite?: number;
|
|
25
|
-
}, projectInfo: ProjectInfo, pluginVersion: string): void;
|
|
26
|
+
export declare function printBanner(viteConfig: ResolvedConfig, options: BannerOptions): void;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { startSandbox } from './server';
|
|
5
5
|
export { extractProjectInfo } from './project-info';
|
|
6
|
-
export { detectTimebackOptions, getEffectiveTimebackId, hasTimebackCredentials, validateTimebackConfig, generateTimebackJson, } from './timeback';
|
|
6
|
+
export { detectTimebackOptions, getEffectiveTimebackId, hasTimebackCredentials, validateTimebackConfig, generateTimebackJson, resolveOrganization, } from './timeback';
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Project information extraction for sandbox initialization
|
|
3
3
|
*/
|
|
4
4
|
import type { ResolvedConfig } from 'vite';
|
|
5
|
-
import type { ProjectInfo } from '../../types';
|
|
6
|
-
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
5
|
+
import type { PlaycademyTimebackOptions, ProjectInfo } from '../../types';
|
|
7
6
|
/**
|
|
8
7
|
* Extracts project information from playcademy.config and package.json
|
|
9
8
|
* Used to initialize sandbox with correct project metadata
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import type { ResolvedConfig } from 'vite';
|
|
2
|
-
import type { SandboxManager } from '../../types';
|
|
3
|
-
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
2
|
+
import type { PlaycademyTimebackOptions, SandboxManager } from '../../types';
|
|
4
3
|
export declare function startSandbox(viteConfig: ResolvedConfig, autoStart?: boolean, options?: {
|
|
4
|
+
port?: number;
|
|
5
5
|
verbose?: boolean;
|
|
6
6
|
customUrl?: string;
|
|
7
|
-
quiet?: boolean;
|
|
8
7
|
recreateDb?: boolean;
|
|
9
8
|
seed?: boolean;
|
|
10
9
|
memoryOnly?: boolean;
|
|
11
10
|
databasePath?: string;
|
|
12
|
-
realtimeEnabled?: boolean;
|
|
13
|
-
realtimePort?: number;
|
|
14
11
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
-
|
|
16
|
-
timebackOptions?: PlaycademyTimebackOptions;
|
|
12
|
+
timebackOptions?: PlaycademyTimebackOptions | false;
|
|
17
13
|
}): Promise<SandboxManager>;
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResolvedConfig } from 'vite';
|
|
5
5
|
import type { TimebackConfig } from '@playcademy/sandbox/config';
|
|
6
|
+
import type { TimebackPluginContext } from '../../types';
|
|
6
7
|
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
7
8
|
/**
|
|
8
|
-
* Get the effective
|
|
9
|
+
* Get the effective Timeback ID - defaults to 'mock' if courses are configured
|
|
9
10
|
*/
|
|
10
|
-
export declare function getEffectiveTimebackId(timeback?: Pick<PlaycademyTimebackOptions, '
|
|
11
|
+
export declare function getEffectiveTimebackId(timeback?: Pick<PlaycademyTimebackOptions, 'id' | 'courses'>): string | undefined;
|
|
11
12
|
/**
|
|
12
13
|
* Auto-detect TimeBack configuration from environment variables
|
|
13
14
|
*
|
|
@@ -23,10 +24,34 @@ export declare function hasTimebackCredentials(): boolean;
|
|
|
23
24
|
* Validate TimeBack config and warn if real course IDs are used without credentials
|
|
24
25
|
*/
|
|
25
26
|
export declare function validateTimebackConfig(viteConfig: ResolvedConfig, timeback?: PlaycademyTimebackOptions): void;
|
|
27
|
+
type OrgType = 'school' | 'district' | 'department' | 'local' | 'state' | 'national';
|
|
28
|
+
/** SDK-compatible organization shape (includes isPrimary for array format) */
|
|
29
|
+
type SdkOrganization = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string | null;
|
|
32
|
+
type: string;
|
|
33
|
+
isPrimary: boolean;
|
|
34
|
+
};
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
36
|
+
* Resolve organization config to a normalized object.
|
|
37
|
+
* Used by sandbox config which expects a single organization.
|
|
38
|
+
* Merges provided values with defaults - only override what you need.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveOrganization(orgConfig: PlaycademyTimebackOptions['organization']): {
|
|
41
|
+
id: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
type?: OrgType;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Resolve organization config into SDK-compatible organizations array.
|
|
47
|
+
* In dev mode we always have one primary org; defaults to Playcademy mock org.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveOrganizations(orgConfig: PlaycademyTimebackOptions['organization']): SdkOrganization[];
|
|
50
|
+
/**
|
|
51
|
+
* Generate TimeBack data JSON for the game shell.
|
|
29
52
|
*
|
|
30
|
-
* @
|
|
53
|
+
* @param context - TimeBack context with base courses and optional overrides
|
|
54
|
+
* @returns JSON string with { role, enrollments, organizations }, or 'null' if no courses
|
|
31
55
|
*/
|
|
32
|
-
export declare function generateTimebackJson(
|
|
56
|
+
export declare function generateTimebackJson(context?: TimebackPluginContext): string;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Game Token Generator
|
|
3
|
+
*
|
|
4
|
+
* Creates a simple JWT-like token for local development that mimics
|
|
5
|
+
* the platform's game token structure. The sandbox auth will parse
|
|
6
|
+
* this token to extract the game slug and user ID.
|
|
7
|
+
*
|
|
8
|
+
* Format: base64(header).base64(payload).signature
|
|
9
|
+
* Where:
|
|
10
|
+
* - header: { "alg": "none", "typ": "sandbox" }
|
|
11
|
+
* - payload: { "sub": gameSlug, "uid": demoUserId }
|
|
12
|
+
* - signature: "sandbox" (not cryptographically verified)
|
|
13
|
+
*/
|
|
14
|
+
import type { PlatformRoleOverride } from '../../types';
|
|
15
|
+
/**
|
|
16
|
+
* Create a sandbox game token
|
|
17
|
+
*
|
|
18
|
+
* This token allows the sandbox auth to identify both the user
|
|
19
|
+
* and the game context, mimicking how the platform issues game JWTs.
|
|
20
|
+
*
|
|
21
|
+
* @param gameSlug - The game's slug (used to look up game in sandbox DB)
|
|
22
|
+
* @param role - Platform role (defaults to 'player')
|
|
23
|
+
* @returns JWT-like token string
|
|
24
|
+
*/
|
|
25
|
+
export declare function createSandboxGameToken(gameSlug: string, role?: PlatformRoleOverride): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watch for config file changes and recreate sandbox
|
|
3
|
+
*
|
|
4
|
+
* Watches both playcademy.config.* and vite.config.* files.
|
|
5
|
+
* When either changes, the sandbox database is recreated automatically.
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
8
|
+
import type { PlatformModeOptions } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Setup file watcher for config file changes
|
|
11
|
+
*
|
|
12
|
+
* Watches playcademy.config.* and vite.config.* files.
|
|
13
|
+
* When either changes, the sandbox database is automatically recreated.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setupConfigWatcher(server: ViteDevServer, viteConfig: ResolvedConfig, platformModeOptions: PlatformModeOptions): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 'p' hotkey - cycle platform user role (player/developer/admin)
|
|
3
|
+
*/
|
|
4
|
+
import type { HotkeyOptions } from '../../types';
|
|
5
|
+
export declare const cyclePlatformRoleHotkey: (options: HotkeyOptions) => {
|
|
6
|
+
key: string;
|
|
7
|
+
description: string;
|
|
8
|
+
action: () => void;
|
|
9
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
|
-
import type { SandboxManager } from '../types';
|
|
3
|
-
import type { PlaycademyTimebackOptions } from '../types/options';
|
|
2
|
+
import type { SandboxManager, TimebackPluginContext } from '../types';
|
|
4
3
|
export interface ShellOptions {
|
|
5
|
-
|
|
6
|
-
timeback?:
|
|
4
|
+
hideBadge: boolean;
|
|
5
|
+
timeback?: TimebackPluginContext;
|
|
7
6
|
}
|
|
8
7
|
export declare function devServerMiddleware(server: ViteDevServer, sandbox: SandboxManager, gameUrl: string | undefined, options: ShellOptions): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility for recreating the sandbox database
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedConfig } from 'vite';
|
|
5
|
+
import type { PlatformModeOptions } from '../types';
|
|
6
|
+
export interface RecreateSandboxOptions {
|
|
7
|
+
viteConfig: ResolvedConfig;
|
|
8
|
+
platformModeOptions: PlatformModeOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface RecreateSandboxResult {
|
|
11
|
+
success: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Recreate the sandbox database
|
|
16
|
+
*
|
|
17
|
+
* This is a shared utility used by:
|
|
18
|
+
* - 'd' hotkey (manual recreation)
|
|
19
|
+
* - Config file watcher (automatic recreation on playcademy.config.js changes)
|
|
20
|
+
*/
|
|
21
|
+
export declare function recreateSandbox(options: RecreateSandboxOptions): Promise<RecreateSandboxResult>;
|
package/dist/server/state.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* these references at module scope to properly clean them up on restart.
|
|
8
8
|
*/
|
|
9
9
|
import type { ViteDevServer } from 'vite';
|
|
10
|
-
import type { CliServerManager, SandboxManager, TimebackRoleOverride } from '../types';
|
|
10
|
+
import type { CliServerManager, PlatformRoleOverride, SandboxManager, TimebackRoleOverride } from '../types';
|
|
11
11
|
import type { PlaycademyMode } from '../types/options';
|
|
12
12
|
/**
|
|
13
13
|
* Module-level server references
|
|
@@ -18,6 +18,7 @@ export declare const serverState: {
|
|
|
18
18
|
viteServer: ViteDevServer | null;
|
|
19
19
|
currentMode: PlaycademyMode;
|
|
20
20
|
timebackRoleOverride: TimebackRoleOverride | null;
|
|
21
|
+
platformRoleOverride: PlatformRoleOverride | null;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
24
|
* Get sandbox server reference
|
|
@@ -63,3 +64,11 @@ export declare function getTimebackRoleOverride(): TimebackRoleOverride | null;
|
|
|
63
64
|
* Set TimeBack role override
|
|
64
65
|
*/
|
|
65
66
|
export declare function setTimebackRoleOverride(role: TimebackRoleOverride | null): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get current platform role override
|
|
69
|
+
*/
|
|
70
|
+
export declare function getPlatformRoleOverride(): PlatformRoleOverride | null;
|
|
71
|
+
/**
|
|
72
|
+
* Set platform role override
|
|
73
|
+
*/
|
|
74
|
+
export declare function setPlatformRoleOverride(role: PlatformRoleOverride | null): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type exports for the Playcademy Vite Plugin
|
|
3
3
|
*/
|
|
4
|
-
export type { PlaycademyExportOptions, PlaycademySandboxOptions,
|
|
5
|
-
export type {
|
|
6
|
-
export { TIMEBACK_ROLES } from './internal';
|
|
4
|
+
export type { PlaycademyExportOptions, PlaycademySandboxOptions, PlaycademyDisplayOptions, PlaycademyPluginOptions, PlaycademyTimebackOptions, PlaycademyMode, } from './options';
|
|
5
|
+
export type { BannerOptions, CliDevServerOptions, CliServerManager, HotkeyOptions, PlatformModeOptions, PlatformRoleOverride, PlaycademyOutputData, PluginContext, ProjectInfo, ResolvedPluginOptions, SandboxManager, StandaloneModeOptions, TimebackCourseConfig, TimebackPluginContext, TimebackRoleOverride, } from './internal';
|
|
6
|
+
export { TIMEBACK_ROLES, PLATFORM_ROLES } from './internal';
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ import type { PlaycademyMode, PlaycademyTimebackOptions } from './options';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const TIMEBACK_ROLES: readonly ["student", "parent", "teacher", "administrator"];
|
|
10
10
|
export type TimebackRoleOverride = (typeof TIMEBACK_ROLES)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Platform roles that can be cycled through in dev mode
|
|
13
|
+
*/
|
|
14
|
+
export declare const PLATFORM_ROLES: readonly ["player", "developer", "admin"];
|
|
15
|
+
export type PlatformRoleOverride = (typeof PLATFORM_ROLES)[number];
|
|
11
16
|
/**
|
|
12
17
|
* Internal resolved plugin options
|
|
13
18
|
*/
|
|
@@ -23,10 +28,8 @@ export interface ResolvedPluginOptions {
|
|
|
23
28
|
seed: boolean;
|
|
24
29
|
memoryOnly: boolean;
|
|
25
30
|
databasePath?: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
showBadge: boolean;
|
|
29
|
-
timeback?: PlaycademyTimebackOptions;
|
|
31
|
+
hideBadge: boolean;
|
|
32
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Plugin context shared across hooks
|
|
@@ -35,6 +38,7 @@ export interface PluginContext {
|
|
|
35
38
|
options: ResolvedPluginOptions;
|
|
36
39
|
viteConfig: ResolvedConfig | null;
|
|
37
40
|
backendPort: number | null;
|
|
41
|
+
sandboxPort: number | null;
|
|
38
42
|
buildOutputs: PlaycademyOutputData;
|
|
39
43
|
}
|
|
40
44
|
/**
|
|
@@ -56,6 +60,19 @@ export interface TimebackCourseConfig {
|
|
|
56
60
|
totalXp?: number | null;
|
|
57
61
|
masterableUnits?: number | null;
|
|
58
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Combined TimeBack context for vite-plugin internal use.
|
|
65
|
+
* Bundles base courses (from config) with user overrides (from plugin options).
|
|
66
|
+
*
|
|
67
|
+
* NOTE: This is different from SDK's TimebackInitContext which is the
|
|
68
|
+
* payload sent to games. This is for plugin configuration bundling.
|
|
69
|
+
*/
|
|
70
|
+
export interface TimebackPluginContext {
|
|
71
|
+
/** Base courses from playcademy.config.js */
|
|
72
|
+
baseCourses: TimebackCourseConfig[];
|
|
73
|
+
/** User overrides from vite.config.ts plugin options */
|
|
74
|
+
overrides?: PlaycademyTimebackOptions;
|
|
75
|
+
}
|
|
59
76
|
/**
|
|
60
77
|
* Project information extracted from package.json and directory structure
|
|
61
78
|
*/
|
|
@@ -71,11 +88,11 @@ export interface ProjectInfo {
|
|
|
71
88
|
*/
|
|
72
89
|
export interface SandboxManager {
|
|
73
90
|
baseUrl: string;
|
|
74
|
-
realtimeUrl: string;
|
|
75
91
|
port: number;
|
|
76
|
-
realtimePort?: number;
|
|
77
92
|
project: ProjectInfo | null;
|
|
78
|
-
|
|
93
|
+
timebackMode?: 'mock' | 'remote' | 'local' | null;
|
|
94
|
+
setRole?: (role: TimebackRoleOverride) => void;
|
|
95
|
+
cleanup: () => void | Promise<void>;
|
|
79
96
|
}
|
|
80
97
|
/**
|
|
81
98
|
* CLI server manager interface for controlling backend server lifecycle
|
|
@@ -92,7 +109,7 @@ export interface CliServerManager {
|
|
|
92
109
|
* Options for setting up the CLI dev server
|
|
93
110
|
*/
|
|
94
111
|
export interface CliDevServerOptions {
|
|
95
|
-
|
|
112
|
+
port: number;
|
|
96
113
|
viteConfig: ResolvedConfig;
|
|
97
114
|
platformUrl?: string;
|
|
98
115
|
configPath?: string;
|
|
@@ -102,6 +119,7 @@ export interface CliDevServerOptions {
|
|
|
102
119
|
*/
|
|
103
120
|
export interface PlatformModeOptions {
|
|
104
121
|
startSandbox: boolean;
|
|
122
|
+
sandboxPort: number;
|
|
105
123
|
verbose: boolean;
|
|
106
124
|
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
107
125
|
sandboxUrl: string;
|
|
@@ -109,18 +127,16 @@ export interface PlatformModeOptions {
|
|
|
109
127
|
seed: boolean;
|
|
110
128
|
memoryOnly: boolean;
|
|
111
129
|
databasePath?: string;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
showBadge: boolean;
|
|
115
|
-
preferredBackendPort: number;
|
|
130
|
+
hideBadge: boolean;
|
|
131
|
+
backendPort: number;
|
|
116
132
|
configPath?: string;
|
|
117
|
-
timeback?: PlaycademyTimebackOptions;
|
|
133
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
118
134
|
}
|
|
119
135
|
/**
|
|
120
136
|
* Options for standalone mode (backend only)
|
|
121
137
|
*/
|
|
122
138
|
export interface StandaloneModeOptions {
|
|
123
|
-
|
|
139
|
+
backendPort: number;
|
|
124
140
|
configPath?: string;
|
|
125
141
|
}
|
|
126
142
|
/**
|
|
@@ -130,3 +146,31 @@ export interface HotkeyOptions {
|
|
|
130
146
|
viteConfig: ResolvedConfig;
|
|
131
147
|
platformModeOptions: PlatformModeOptions;
|
|
132
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Options for the startup banner
|
|
151
|
+
*/
|
|
152
|
+
export interface BannerOptions {
|
|
153
|
+
/** Plugin version */
|
|
154
|
+
version: string;
|
|
155
|
+
/** Game/project name (platform mode only) */
|
|
156
|
+
gameName?: string;
|
|
157
|
+
/** Sandbox server info */
|
|
158
|
+
sandbox?: {
|
|
159
|
+
port: number;
|
|
160
|
+
enabled: true;
|
|
161
|
+
} | {
|
|
162
|
+
enabled: false;
|
|
163
|
+
};
|
|
164
|
+
/** Backend server info */
|
|
165
|
+
backend?: {
|
|
166
|
+
port: number;
|
|
167
|
+
/** Vite port for proxied URL display */
|
|
168
|
+
vitePort?: number;
|
|
169
|
+
};
|
|
170
|
+
/** Timeback info (platform mode only) */
|
|
171
|
+
timeback?: {
|
|
172
|
+
courseCount: number;
|
|
173
|
+
enrolledCount: number;
|
|
174
|
+
mode: 'mock' | 'remote' | 'local';
|
|
175
|
+
};
|
|
176
|
+
}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -174,63 +174,40 @@ export interface PlaycademySandboxOptions {
|
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
176
|
databasePath?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Real-time/WebSocket server configuration.
|
|
179
|
-
*
|
|
180
|
-
* The real-time server provides WebSocket support for live updates,
|
|
181
|
-
* multiplayer features, and other real-time functionality.
|
|
182
|
-
*
|
|
183
|
-
* @default { enabled: false }
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* sandbox: {
|
|
187
|
-
* realtime: {
|
|
188
|
-
* enabled: true,
|
|
189
|
-
* port: 4322 // Custom WebSocket port
|
|
190
|
-
* }
|
|
191
|
-
* }
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
realtime?: {
|
|
195
|
-
/**
|
|
196
|
-
* Enable the real-time/WebSocket server.
|
|
197
|
-
*
|
|
198
|
-
* @default false
|
|
199
|
-
*/
|
|
200
|
-
enabled?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Port for the WebSocket server.
|
|
203
|
-
*
|
|
204
|
-
* By default, uses the HTTP port + 1 (e.g., if HTTP is 4321,
|
|
205
|
-
* WebSocket will be 4322).
|
|
206
|
-
*/
|
|
207
|
-
port?: number;
|
|
208
|
-
};
|
|
209
177
|
}
|
|
210
178
|
/**
|
|
211
|
-
*
|
|
179
|
+
* Timeback integration configuration for local development.
|
|
180
|
+
*
|
|
181
|
+
* By default, all courses from playcademy.config.js are enrolled with mock IDs.
|
|
182
|
+
* Use this to override specific courses or exclude them from enrollment.
|
|
212
183
|
*
|
|
213
184
|
* @example
|
|
214
185
|
* ```ts
|
|
215
|
-
* //
|
|
186
|
+
* // Use all defaults (all courses from config with mock IDs)
|
|
187
|
+
* timeback: {}
|
|
188
|
+
*
|
|
189
|
+
* // Override role only (still enrolls all courses with mock IDs)
|
|
190
|
+
* timeback: {
|
|
191
|
+
* role: 'teacher',
|
|
192
|
+
* }
|
|
193
|
+
*
|
|
194
|
+
* // Override specific course with real ID (others still use mock)
|
|
216
195
|
* timeback: {
|
|
217
196
|
* courses: {
|
|
218
|
-
* 'FastMath:3': '
|
|
219
|
-
* 'FastMath:4': 'mock',
|
|
197
|
+
* 'FastMath:3': 'real-course-id-g3',
|
|
220
198
|
* },
|
|
221
199
|
* }
|
|
222
200
|
*
|
|
223
|
-
* //
|
|
201
|
+
* // Exclude a course from enrollment (test partial enrollment)
|
|
224
202
|
* timeback: {
|
|
225
|
-
* role: 'parent',
|
|
226
203
|
* courses: {
|
|
227
|
-
* 'FastMath:
|
|
204
|
+
* 'FastMath:4': false, // Not enrolled in grade 4
|
|
228
205
|
* },
|
|
229
206
|
* }
|
|
230
207
|
*
|
|
231
|
-
* //
|
|
208
|
+
* // Full real Timeback integration
|
|
232
209
|
* timeback: {
|
|
233
|
-
*
|
|
210
|
+
* id: 'real-student-sourced-id',
|
|
234
211
|
* courses: {
|
|
235
212
|
* 'FastMath:3': 'real-course-id-g3',
|
|
236
213
|
* 'FastMath:4': 'real-course-id-g4',
|
|
@@ -240,20 +217,38 @@ export interface PlaycademySandboxOptions {
|
|
|
240
217
|
*/
|
|
241
218
|
export interface PlaycademyTimebackOptions {
|
|
242
219
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
220
|
+
* Timeback ID for the test user. Defaults to auto-generated mock ID.
|
|
221
|
+
* Set to a real student sourcedId for testing against real Timeback.
|
|
245
222
|
*/
|
|
246
|
-
|
|
223
|
+
id?: string;
|
|
247
224
|
/**
|
|
248
225
|
* User role for testing. Defaults to 'student'.
|
|
249
226
|
* Use this to test parent/teacher views of your game.
|
|
250
227
|
*/
|
|
251
228
|
role?: 'student' | 'parent' | 'teacher' | 'administrator' | 'guardian';
|
|
252
229
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
230
|
+
* Organization (school/district) configuration.
|
|
231
|
+
* Defaults to PLAYCADEMY mock organization. All properties are optional -
|
|
232
|
+
* only override what you need.
|
|
233
|
+
*/
|
|
234
|
+
organization?: 'mock' | {
|
|
235
|
+
/** Organization sourcedId (defaults to PLAYCADEMY) */
|
|
236
|
+
id?: string;
|
|
237
|
+
/** Organization display name (defaults to 'Playcademy Studios') */
|
|
238
|
+
name?: string;
|
|
239
|
+
/** Organization type (defaults to 'department') */
|
|
240
|
+
type?: 'school' | 'district' | 'department' | 'local' | 'state' | 'national';
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Course enrollment overrides. By default, all courses from playcademy.config.js
|
|
244
|
+
* are enrolled with mock IDs.
|
|
245
|
+
*
|
|
246
|
+
* - Omit entirely: Use all courses from config with mock IDs
|
|
247
|
+
* - `'mock'` or omit key: Use mock ID for that course
|
|
248
|
+
* - Real string: Use that course ID
|
|
249
|
+
* - `null` or `false`: Exclude from enrollment
|
|
255
250
|
*/
|
|
256
|
-
courses
|
|
251
|
+
courses?: Record<string, 'mock' | string | null | false>;
|
|
257
252
|
}
|
|
258
253
|
/**
|
|
259
254
|
* Configuration options for the development shell wrapper
|
|
@@ -261,19 +256,19 @@ export interface PlaycademyTimebackOptions {
|
|
|
261
256
|
* The shell provides the platform UI during development, including the
|
|
262
257
|
* Playcademy badge, game selection, and other platform features.
|
|
263
258
|
*/
|
|
264
|
-
export interface
|
|
259
|
+
export interface PlaycademyDisplayOptions {
|
|
265
260
|
/**
|
|
266
|
-
*
|
|
261
|
+
* Hide the Playcademy badge in the corner during development.
|
|
267
262
|
*
|
|
268
|
-
* @default
|
|
263
|
+
* @default false
|
|
269
264
|
* @example
|
|
270
265
|
* ```ts
|
|
271
|
-
*
|
|
272
|
-
*
|
|
266
|
+
* display: {
|
|
267
|
+
* hideBadge: true // Hide the badge
|
|
273
268
|
* }
|
|
274
269
|
* ```
|
|
275
270
|
*/
|
|
276
|
-
|
|
271
|
+
hideBadge?: boolean;
|
|
277
272
|
}
|
|
278
273
|
/**
|
|
279
274
|
* Main configuration options for the Playcademy Vite plugin
|
|
@@ -294,8 +289,8 @@ export interface PlaycademyShellOptions {
|
|
|
294
289
|
* logLevel: 'debug',
|
|
295
290
|
* recreateDb: true
|
|
296
291
|
* },
|
|
297
|
-
*
|
|
298
|
-
*
|
|
292
|
+
* display: {
|
|
293
|
+
* hideBadge: true
|
|
299
294
|
* }
|
|
300
295
|
* })
|
|
301
296
|
* ]
|
|
@@ -368,25 +363,25 @@ export interface PlaycademyPluginOptions {
|
|
|
368
363
|
*/
|
|
369
364
|
sandbox?: PlaycademySandboxOptions;
|
|
370
365
|
/**
|
|
371
|
-
*
|
|
366
|
+
* Display configuration options.
|
|
372
367
|
*
|
|
373
|
-
*
|
|
368
|
+
* Control visual elements during development.
|
|
374
369
|
*
|
|
375
370
|
* @example
|
|
376
371
|
* ```ts
|
|
377
372
|
* {
|
|
378
|
-
*
|
|
379
|
-
*
|
|
373
|
+
* display: {
|
|
374
|
+
* hideBadge: true
|
|
380
375
|
* }
|
|
381
376
|
* }
|
|
382
377
|
* ```
|
|
383
378
|
*/
|
|
384
|
-
|
|
379
|
+
display?: PlaycademyDisplayOptions;
|
|
385
380
|
/**
|
|
386
|
-
*
|
|
381
|
+
* Timeback integration configuration.
|
|
387
382
|
*
|
|
388
|
-
* Configure mock or real
|
|
389
|
-
* `
|
|
383
|
+
* Configure mock or real Timeback enrollments for local development.
|
|
384
|
+
* Timeback `id` is auto-generated for mock testing.
|
|
390
385
|
*
|
|
391
386
|
* @example
|
|
392
387
|
* ```ts
|
|
@@ -397,6 +392,8 @@ export interface PlaycademyPluginOptions {
|
|
|
397
392
|
* },
|
|
398
393
|
* }
|
|
399
394
|
* ```
|
|
395
|
+
*
|
|
396
|
+
* Set to `false` to explicitly disable Timeback even if configured in playcademy.config.
|
|
400
397
|
*/
|
|
401
|
-
timeback?: PlaycademyTimebackOptions;
|
|
398
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
402
399
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"pub": "bun publish.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@playcademy/utils": "0.0.1",
|
|
22
23
|
"archiver": "^7.0.1",
|
|
23
24
|
"picocolors": "^1.1.1",
|
|
24
|
-
"playcademy": "0.14.
|
|
25
|
+
"playcademy": "0.14.27"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@inquirer/prompts": "^7.8.6",
|
|
28
|
-
"@playcademy/sandbox": "0.
|
|
29
|
+
"@playcademy/sandbox": "0.3.6",
|
|
29
30
|
"@types/archiver": "^6.0.3",
|
|
30
31
|
"@types/bun": "latest"
|
|
31
32
|
},
|