@playcademy/vite-plugin 0.1.40 → 0.2.0
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 +76 -17
- package/dist/index.js +1395 -1006
- 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 -5
- 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 +59 -8
- package/dist/types/options.d.ts +61 -32
- 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): 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,10 +1,9 @@
|
|
|
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;
|
|
@@ -12,6 +11,5 @@ export declare function startSandbox(viteConfig: ResolvedConfig, autoStart?: boo
|
|
|
12
11
|
realtimeEnabled?: boolean;
|
|
13
12
|
realtimePort?: number;
|
|
14
13
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
-
|
|
16
|
-
timebackOptions?: PlaycademyTimebackOptions;
|
|
14
|
+
timebackOptions?: PlaycademyTimebackOptions | false;
|
|
17
15
|
}): 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
|
*/
|
|
@@ -25,8 +30,8 @@ export interface ResolvedPluginOptions {
|
|
|
25
30
|
databasePath?: string;
|
|
26
31
|
realtimeEnabled: boolean;
|
|
27
32
|
realtimePort?: number;
|
|
28
|
-
|
|
29
|
-
timeback?: PlaycademyTimebackOptions;
|
|
33
|
+
hideBadge: boolean;
|
|
34
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Plugin context shared across hooks
|
|
@@ -35,6 +40,7 @@ export interface PluginContext {
|
|
|
35
40
|
options: ResolvedPluginOptions;
|
|
36
41
|
viteConfig: ResolvedConfig | null;
|
|
37
42
|
backendPort: number | null;
|
|
43
|
+
sandboxPort: number | null;
|
|
38
44
|
buildOutputs: PlaycademyOutputData;
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
@@ -56,6 +62,19 @@ export interface TimebackCourseConfig {
|
|
|
56
62
|
totalXp?: number | null;
|
|
57
63
|
masterableUnits?: number | null;
|
|
58
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Combined TimeBack context for vite-plugin internal use.
|
|
67
|
+
* Bundles base courses (from config) with user overrides (from plugin options).
|
|
68
|
+
*
|
|
69
|
+
* NOTE: This is different from SDK's TimebackInitContext which is the
|
|
70
|
+
* payload sent to games. This is for plugin configuration bundling.
|
|
71
|
+
*/
|
|
72
|
+
export interface TimebackPluginContext {
|
|
73
|
+
/** Base courses from playcademy.config.js */
|
|
74
|
+
baseCourses: TimebackCourseConfig[];
|
|
75
|
+
/** User overrides from vite.config.ts plugin options */
|
|
76
|
+
overrides?: PlaycademyTimebackOptions;
|
|
77
|
+
}
|
|
59
78
|
/**
|
|
60
79
|
* Project information extracted from package.json and directory structure
|
|
61
80
|
*/
|
|
@@ -75,7 +94,9 @@ export interface SandboxManager {
|
|
|
75
94
|
port: number;
|
|
76
95
|
realtimePort?: number;
|
|
77
96
|
project: ProjectInfo | null;
|
|
78
|
-
|
|
97
|
+
timebackMode?: 'mock' | 'remote' | 'local' | null;
|
|
98
|
+
setRole?: (role: TimebackRoleOverride) => void;
|
|
99
|
+
cleanup: () => void | Promise<void>;
|
|
79
100
|
}
|
|
80
101
|
/**
|
|
81
102
|
* CLI server manager interface for controlling backend server lifecycle
|
|
@@ -92,7 +113,7 @@ export interface CliServerManager {
|
|
|
92
113
|
* Options for setting up the CLI dev server
|
|
93
114
|
*/
|
|
94
115
|
export interface CliDevServerOptions {
|
|
95
|
-
|
|
116
|
+
port: number;
|
|
96
117
|
viteConfig: ResolvedConfig;
|
|
97
118
|
platformUrl?: string;
|
|
98
119
|
configPath?: string;
|
|
@@ -102,6 +123,7 @@ export interface CliDevServerOptions {
|
|
|
102
123
|
*/
|
|
103
124
|
export interface PlatformModeOptions {
|
|
104
125
|
startSandbox: boolean;
|
|
126
|
+
sandboxPort: number;
|
|
105
127
|
verbose: boolean;
|
|
106
128
|
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
107
129
|
sandboxUrl: string;
|
|
@@ -111,16 +133,16 @@ export interface PlatformModeOptions {
|
|
|
111
133
|
databasePath?: string;
|
|
112
134
|
realtimeEnabled: boolean;
|
|
113
135
|
realtimePort?: number;
|
|
114
|
-
|
|
115
|
-
|
|
136
|
+
hideBadge: boolean;
|
|
137
|
+
backendPort: number;
|
|
116
138
|
configPath?: string;
|
|
117
|
-
timeback?: PlaycademyTimebackOptions;
|
|
139
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
118
140
|
}
|
|
119
141
|
/**
|
|
120
142
|
* Options for standalone mode (backend only)
|
|
121
143
|
*/
|
|
122
144
|
export interface StandaloneModeOptions {
|
|
123
|
-
|
|
145
|
+
backendPort: number;
|
|
124
146
|
configPath?: string;
|
|
125
147
|
}
|
|
126
148
|
/**
|
|
@@ -130,3 +152,32 @@ export interface HotkeyOptions {
|
|
|
130
152
|
viteConfig: ResolvedConfig;
|
|
131
153
|
platformModeOptions: PlatformModeOptions;
|
|
132
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Options for the startup banner
|
|
157
|
+
*/
|
|
158
|
+
export interface BannerOptions {
|
|
159
|
+
/** Plugin version */
|
|
160
|
+
version: string;
|
|
161
|
+
/** Game/project name (platform mode only) */
|
|
162
|
+
gameName?: string;
|
|
163
|
+
/** Sandbox server info */
|
|
164
|
+
sandbox?: {
|
|
165
|
+
port: number;
|
|
166
|
+
enabled: true;
|
|
167
|
+
} | {
|
|
168
|
+
enabled: false;
|
|
169
|
+
};
|
|
170
|
+
/** Backend server info */
|
|
171
|
+
backend?: {
|
|
172
|
+
port: number;
|
|
173
|
+
/** Vite port for proxied URL display */
|
|
174
|
+
vitePort?: number;
|
|
175
|
+
};
|
|
176
|
+
/** Realtime server port (platform mode only) */
|
|
177
|
+
realtimePort?: number;
|
|
178
|
+
/** Timeback info (platform mode only) */
|
|
179
|
+
timeback?: {
|
|
180
|
+
courseCount: number;
|
|
181
|
+
mode: 'mock' | 'remote' | 'local';
|
|
182
|
+
};
|
|
183
|
+
}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -208,29 +208,38 @@ export interface PlaycademySandboxOptions {
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
211
|
-
*
|
|
211
|
+
* Timeback integration configuration for local development.
|
|
212
|
+
*
|
|
213
|
+
* By default, all courses from playcademy.config.js are enrolled with mock IDs.
|
|
214
|
+
* Use this to override specific courses or exclude them from enrollment.
|
|
212
215
|
*
|
|
213
216
|
* @example
|
|
214
217
|
* ```ts
|
|
215
|
-
* //
|
|
218
|
+
* // Use all defaults (all courses from config with mock IDs)
|
|
219
|
+
* timeback: {}
|
|
220
|
+
*
|
|
221
|
+
* // Override role only (still enrolls all courses with mock IDs)
|
|
222
|
+
* timeback: {
|
|
223
|
+
* role: 'teacher',
|
|
224
|
+
* }
|
|
225
|
+
*
|
|
226
|
+
* // Override specific course with real ID (others still use mock)
|
|
216
227
|
* timeback: {
|
|
217
228
|
* courses: {
|
|
218
|
-
* 'FastMath:3': '
|
|
219
|
-
* 'FastMath:4': 'mock',
|
|
229
|
+
* 'FastMath:3': 'real-course-id-g3',
|
|
220
230
|
* },
|
|
221
231
|
* }
|
|
222
232
|
*
|
|
223
|
-
* //
|
|
233
|
+
* // Exclude a course from enrollment (test partial enrollment)
|
|
224
234
|
* timeback: {
|
|
225
|
-
* role: 'parent',
|
|
226
235
|
* courses: {
|
|
227
|
-
* 'FastMath:
|
|
236
|
+
* 'FastMath:4': null, // Not enrolled in grade 4
|
|
228
237
|
* },
|
|
229
238
|
* }
|
|
230
239
|
*
|
|
231
|
-
* //
|
|
240
|
+
* // Full real Timeback integration
|
|
232
241
|
* timeback: {
|
|
233
|
-
*
|
|
242
|
+
* id: 'real-student-sourced-id',
|
|
234
243
|
* courses: {
|
|
235
244
|
* 'FastMath:3': 'real-course-id-g3',
|
|
236
245
|
* 'FastMath:4': 'real-course-id-g4',
|
|
@@ -240,20 +249,38 @@ export interface PlaycademySandboxOptions {
|
|
|
240
249
|
*/
|
|
241
250
|
export interface PlaycademyTimebackOptions {
|
|
242
251
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
252
|
+
* Timeback ID for the test user. Defaults to auto-generated mock ID.
|
|
253
|
+
* Set to a real student sourcedId for testing against real Timeback.
|
|
245
254
|
*/
|
|
246
|
-
|
|
255
|
+
id?: string;
|
|
247
256
|
/**
|
|
248
257
|
* User role for testing. Defaults to 'student'.
|
|
249
258
|
* Use this to test parent/teacher views of your game.
|
|
250
259
|
*/
|
|
251
260
|
role?: 'student' | 'parent' | 'teacher' | 'administrator' | 'guardian';
|
|
252
261
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
262
|
+
* Organization (school/district) configuration.
|
|
263
|
+
* Defaults to PLAYCADEMY mock organization. All properties are optional -
|
|
264
|
+
* only override what you need.
|
|
255
265
|
*/
|
|
256
|
-
|
|
266
|
+
organization?: 'mock' | {
|
|
267
|
+
/** Organization sourcedId (defaults to PLAYCADEMY) */
|
|
268
|
+
id?: string;
|
|
269
|
+
/** Organization display name (defaults to 'Playcademy Studios') */
|
|
270
|
+
name?: string;
|
|
271
|
+
/** Organization type (defaults to 'department') */
|
|
272
|
+
type?: 'school' | 'district' | 'department' | 'local' | 'state' | 'national';
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Course enrollment overrides. By default, all courses from playcademy.config.js
|
|
276
|
+
* are enrolled with mock IDs.
|
|
277
|
+
*
|
|
278
|
+
* - Omit entirely: Use all courses from config with mock IDs
|
|
279
|
+
* - `'mock'` or omit key: Use mock ID for that course
|
|
280
|
+
* - Real string: Use that course ID
|
|
281
|
+
* - `null`: Exclude from enrollment (test partial enrollment)
|
|
282
|
+
*/
|
|
283
|
+
courses?: Record<string, 'mock' | string | null>;
|
|
257
284
|
}
|
|
258
285
|
/**
|
|
259
286
|
* Configuration options for the development shell wrapper
|
|
@@ -261,19 +288,19 @@ export interface PlaycademyTimebackOptions {
|
|
|
261
288
|
* The shell provides the platform UI during development, including the
|
|
262
289
|
* Playcademy badge, game selection, and other platform features.
|
|
263
290
|
*/
|
|
264
|
-
export interface
|
|
291
|
+
export interface PlaycademyDisplayOptions {
|
|
265
292
|
/**
|
|
266
|
-
*
|
|
293
|
+
* Hide the Playcademy badge in the corner during development.
|
|
267
294
|
*
|
|
268
|
-
* @default
|
|
295
|
+
* @default false
|
|
269
296
|
* @example
|
|
270
297
|
* ```ts
|
|
271
|
-
*
|
|
272
|
-
*
|
|
298
|
+
* display: {
|
|
299
|
+
* hideBadge: true // Hide the badge
|
|
273
300
|
* }
|
|
274
301
|
* ```
|
|
275
302
|
*/
|
|
276
|
-
|
|
303
|
+
hideBadge?: boolean;
|
|
277
304
|
}
|
|
278
305
|
/**
|
|
279
306
|
* Main configuration options for the Playcademy Vite plugin
|
|
@@ -294,8 +321,8 @@ export interface PlaycademyShellOptions {
|
|
|
294
321
|
* logLevel: 'debug',
|
|
295
322
|
* recreateDb: true
|
|
296
323
|
* },
|
|
297
|
-
*
|
|
298
|
-
*
|
|
324
|
+
* display: {
|
|
325
|
+
* hideBadge: true
|
|
299
326
|
* }
|
|
300
327
|
* })
|
|
301
328
|
* ]
|
|
@@ -368,25 +395,25 @@ export interface PlaycademyPluginOptions {
|
|
|
368
395
|
*/
|
|
369
396
|
sandbox?: PlaycademySandboxOptions;
|
|
370
397
|
/**
|
|
371
|
-
*
|
|
398
|
+
* Display configuration options.
|
|
372
399
|
*
|
|
373
|
-
*
|
|
400
|
+
* Control visual elements during development.
|
|
374
401
|
*
|
|
375
402
|
* @example
|
|
376
403
|
* ```ts
|
|
377
404
|
* {
|
|
378
|
-
*
|
|
379
|
-
*
|
|
405
|
+
* display: {
|
|
406
|
+
* hideBadge: true
|
|
380
407
|
* }
|
|
381
408
|
* }
|
|
382
409
|
* ```
|
|
383
410
|
*/
|
|
384
|
-
|
|
411
|
+
display?: PlaycademyDisplayOptions;
|
|
385
412
|
/**
|
|
386
|
-
*
|
|
413
|
+
* Timeback integration configuration.
|
|
387
414
|
*
|
|
388
|
-
* Configure mock or real
|
|
389
|
-
* `
|
|
415
|
+
* Configure mock or real Timeback enrollments for local development.
|
|
416
|
+
* Timeback `id` is auto-generated for mock testing.
|
|
390
417
|
*
|
|
391
418
|
* @example
|
|
392
419
|
* ```ts
|
|
@@ -397,6 +424,8 @@ export interface PlaycademyPluginOptions {
|
|
|
397
424
|
* },
|
|
398
425
|
* }
|
|
399
426
|
* ```
|
|
427
|
+
*
|
|
428
|
+
* Set to `false` to explicitly disable Timeback even if configured in playcademy.config.
|
|
400
429
|
*/
|
|
401
|
-
timeback?: PlaycademyTimebackOptions;
|
|
430
|
+
timeback?: PlaycademyTimebackOptions | false;
|
|
402
431
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.26"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@inquirer/prompts": "^7.8.6",
|
|
28
|
-
"@playcademy/sandbox": "0.
|
|
29
|
+
"@playcademy/sandbox": "0.3.0",
|
|
29
30
|
"@types/archiver": "^6.0.3",
|
|
30
31
|
"@types/bun": "latest"
|
|
31
32
|
},
|