@playcademy/vite-plugin 0.1.37 → 0.1.40
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 +64 -0
- package/dist/index.js +842 -749
- package/dist/lib/sandbox/index.d.ts +1 -1
- package/dist/lib/sandbox/project-info.d.ts +5 -1
- package/dist/lib/sandbox/server.d.ts +3 -0
- package/dist/lib/sandbox/timeback.d.ts +22 -1
- package/dist/server/hotkeys/cycle-timeback-role.d.ts +9 -0
- package/dist/server/hotkeys/index.d.ts +9 -0
- package/dist/server/hotkeys/recreate-database.d.ts +9 -0
- package/dist/server/hotkeys/toggle-mode.d.ts +9 -0
- package/dist/server/middleware.d.ts +6 -1
- package/dist/server/state.d.ts +10 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/internal.d.ts +21 -3
- package/dist/types/options.d.ts +65 -0
- package/package.json +3 -3
- package/dist/server/mode-switcher.d.ts +0 -9
- package/dist/server/recreate-sandbox-database.d.ts +0 -14
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { startSandbox } from './server';
|
|
5
5
|
export { extractProjectInfo } from './project-info';
|
|
6
|
-
export { detectTimebackOptions } from './timeback';
|
|
6
|
+
export { detectTimebackOptions, getEffectiveTimebackId, hasTimebackCredentials, validateTimebackConfig, generateTimebackJson, } from './timeback';
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResolvedConfig } from 'vite';
|
|
5
5
|
import type { ProjectInfo } from '../../types';
|
|
6
|
+
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
6
7
|
/**
|
|
7
8
|
* Extracts project information from playcademy.config and package.json
|
|
8
9
|
* Used to initialize sandbox with correct project metadata
|
|
10
|
+
*
|
|
11
|
+
* @param viteConfig - Resolved Vite configuration
|
|
12
|
+
* @param timebackOptions - Optional timeback options from vite.config.ts for courseId overrides
|
|
9
13
|
*/
|
|
10
|
-
export declare function extractProjectInfo(viteConfig: ResolvedConfig): Promise<ProjectInfo>;
|
|
14
|
+
export declare function extractProjectInfo(viteConfig: ResolvedConfig, timebackOptions?: PlaycademyTimebackOptions): Promise<ProjectInfo>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResolvedConfig } from 'vite';
|
|
2
2
|
import type { SandboxManager } from '../../types';
|
|
3
|
+
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
3
4
|
export declare function startSandbox(viteConfig: ResolvedConfig, autoStart?: boolean, options?: {
|
|
4
5
|
verbose?: boolean;
|
|
5
6
|
customUrl?: string;
|
|
@@ -11,4 +12,6 @@ export declare function startSandbox(viteConfig: ResolvedConfig, autoStart?: boo
|
|
|
11
12
|
realtimeEnabled?: boolean;
|
|
12
13
|
realtimePort?: number;
|
|
13
14
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
+
timebackId?: string;
|
|
16
|
+
timebackOptions?: PlaycademyTimebackOptions;
|
|
14
17
|
}): Promise<SandboxManager>;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TimeBack configuration
|
|
2
|
+
* TimeBack configuration and enrollment utilities
|
|
3
3
|
*/
|
|
4
|
+
import type { ResolvedConfig } from 'vite';
|
|
4
5
|
import type { TimebackConfig } from '@playcademy/sandbox/config';
|
|
6
|
+
import type { PlaycademyTimebackOptions } from '../../types/options';
|
|
7
|
+
/**
|
|
8
|
+
* Get the effective timebackId - defaults to 'mock' if courses are configured
|
|
9
|
+
*/
|
|
10
|
+
export declare function getEffectiveTimebackId(timeback?: Pick<PlaycademyTimebackOptions, 'timebackId' | 'courses'>): string | undefined;
|
|
5
11
|
/**
|
|
6
12
|
* Auto-detect TimeBack configuration from environment variables
|
|
7
13
|
*
|
|
@@ -9,3 +15,18 @@ import type { TimebackConfig } from '@playcademy/sandbox/config';
|
|
|
9
15
|
* Returns undefined if no TimeBack configuration is detected.
|
|
10
16
|
*/
|
|
11
17
|
export declare function detectTimebackOptions(): Partial<TimebackConfig> | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Check if TimeBack credentials are fully configured
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasTimebackCredentials(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Validate TimeBack config and warn if real course IDs are used without credentials
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateTimebackConfig(viteConfig: ResolvedConfig, timeback?: PlaycademyTimebackOptions): void;
|
|
26
|
+
/**
|
|
27
|
+
* Generate TimeBack data JSON from timeback config.
|
|
28
|
+
* Includes role and enrollments for passing to the game shell.
|
|
29
|
+
*
|
|
30
|
+
* @returns JSON string with { role, enrollments } or undefined if no courses configured
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateTimebackJson(timeback?: PlaycademyTimebackOptions): string | undefined;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
2
|
import type { SandboxManager } from '../types';
|
|
3
|
-
|
|
3
|
+
import type { PlaycademyTimebackOptions } from '../types/options';
|
|
4
|
+
export interface ShellOptions {
|
|
5
|
+
showBadge: boolean;
|
|
6
|
+
timeback?: PlaycademyTimebackOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function devServerMiddleware(server: ViteDevServer, sandbox: SandboxManager, gameUrl: string | undefined, options: ShellOptions): void;
|
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 } from '../types';
|
|
10
|
+
import type { CliServerManager, SandboxManager, TimebackRoleOverride } from '../types';
|
|
11
11
|
import type { PlaycademyMode } from '../types/options';
|
|
12
12
|
/**
|
|
13
13
|
* Module-level server references
|
|
@@ -17,6 +17,7 @@ export declare const serverState: {
|
|
|
17
17
|
backend: CliServerManager | null;
|
|
18
18
|
viteServer: ViteDevServer | null;
|
|
19
19
|
currentMode: PlaycademyMode;
|
|
20
|
+
timebackRoleOverride: TimebackRoleOverride | null;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* Get sandbox server reference
|
|
@@ -54,3 +55,11 @@ export declare function getViteServerRef(): ViteDevServer | null;
|
|
|
54
55
|
* Set Vite dev server reference
|
|
55
56
|
*/
|
|
56
57
|
export declare function setViteServerRef(server: ViteDevServer | null): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get current TimeBack role override
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTimebackRoleOverride(): TimebackRoleOverride | null;
|
|
62
|
+
/**
|
|
63
|
+
* Set TimeBack role override
|
|
64
|
+
*/
|
|
65
|
+
export declare function setTimebackRoleOverride(role: TimebackRoleOverride | null): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
* Type exports for the Playcademy Vite Plugin
|
|
3
3
|
*/
|
|
4
4
|
export type { PlaycademyExportOptions, PlaycademySandboxOptions, PlaycademyShellOptions, PlaycademyPluginOptions, PlaycademyMode, } from './options';
|
|
5
|
-
export type { ResolvedPluginOptions, PluginContext, PlaycademyOutputData, ProjectInfo, SandboxManager, CliServerManager, CliDevServerOptions, PlatformModeOptions, StandaloneModeOptions,
|
|
5
|
+
export type { ResolvedPluginOptions, PluginContext, PlaycademyOutputData, ProjectInfo, TimebackCourseConfig, SandboxManager, CliServerManager, CliDevServerOptions, PlatformModeOptions, StandaloneModeOptions, HotkeyOptions, TimebackRoleOverride, } from './internal';
|
|
6
|
+
export { TIMEBACK_ROLES } from './internal';
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Internal plugin state and context types
|
|
3
3
|
*/
|
|
4
4
|
import type { ResolvedConfig } from 'vite';
|
|
5
|
-
import type { PlaycademyMode } from './options';
|
|
5
|
+
import type { PlaycademyMode, PlaycademyTimebackOptions } from './options';
|
|
6
|
+
/**
|
|
7
|
+
* TimeBack roles that can be cycled through in dev mode
|
|
8
|
+
*/
|
|
9
|
+
export declare const TIMEBACK_ROLES: readonly ["student", "parent", "teacher", "administrator"];
|
|
10
|
+
export type TimebackRoleOverride = (typeof TIMEBACK_ROLES)[number];
|
|
6
11
|
/**
|
|
7
12
|
* Internal resolved plugin options
|
|
8
13
|
*/
|
|
@@ -21,6 +26,7 @@ export interface ResolvedPluginOptions {
|
|
|
21
26
|
realtimeEnabled: boolean;
|
|
22
27
|
realtimePort?: number;
|
|
23
28
|
showBadge: boolean;
|
|
29
|
+
timeback?: PlaycademyTimebackOptions;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Plugin context shared across hooks
|
|
@@ -40,6 +46,16 @@ export interface PlaycademyOutputData {
|
|
|
40
46
|
zipPath?: string;
|
|
41
47
|
zipSizeKb?: string;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* TimeBack course configuration from playcademy.config
|
|
51
|
+
*/
|
|
52
|
+
export interface TimebackCourseConfig {
|
|
53
|
+
subject: string;
|
|
54
|
+
grade: number;
|
|
55
|
+
courseId?: string;
|
|
56
|
+
totalXp?: number | null;
|
|
57
|
+
masterableUnits?: number | null;
|
|
58
|
+
}
|
|
43
59
|
/**
|
|
44
60
|
* Project information extracted from package.json and directory structure
|
|
45
61
|
*/
|
|
@@ -48,6 +64,7 @@ export interface ProjectInfo {
|
|
|
48
64
|
displayName: string;
|
|
49
65
|
version: string;
|
|
50
66
|
description?: string;
|
|
67
|
+
timebackCourses?: TimebackCourseConfig[];
|
|
51
68
|
}
|
|
52
69
|
/**
|
|
53
70
|
* Sandbox manager interface for controlling sandbox lifecycle
|
|
@@ -97,6 +114,7 @@ export interface PlatformModeOptions {
|
|
|
97
114
|
showBadge: boolean;
|
|
98
115
|
preferredBackendPort: number;
|
|
99
116
|
configPath?: string;
|
|
117
|
+
timeback?: PlaycademyTimebackOptions;
|
|
100
118
|
}
|
|
101
119
|
/**
|
|
102
120
|
* Options for standalone mode (backend only)
|
|
@@ -106,9 +124,9 @@ export interface StandaloneModeOptions {
|
|
|
106
124
|
configPath?: string;
|
|
107
125
|
}
|
|
108
126
|
/**
|
|
109
|
-
* Options for mode switching
|
|
127
|
+
* Options for hotkeys and mode switching
|
|
110
128
|
*/
|
|
111
|
-
export interface
|
|
129
|
+
export interface HotkeyOptions {
|
|
112
130
|
viteConfig: ResolvedConfig;
|
|
113
131
|
platformModeOptions: PlatformModeOptions;
|
|
114
132
|
}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -207,6 +207,54 @@ export interface PlaycademySandboxOptions {
|
|
|
207
207
|
port?: number;
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* TimeBack integration configuration for local development
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* // Mock enrollments (timebackId auto-generated, role defaults to 'student')
|
|
216
|
+
* timeback: {
|
|
217
|
+
* courses: {
|
|
218
|
+
* 'FastMath:3': 'mock',
|
|
219
|
+
* 'FastMath:4': 'mock',
|
|
220
|
+
* },
|
|
221
|
+
* }
|
|
222
|
+
*
|
|
223
|
+
* // Testing as a parent viewing their child's progress
|
|
224
|
+
* timeback: {
|
|
225
|
+
* role: 'parent',
|
|
226
|
+
* courses: {
|
|
227
|
+
* 'FastMath:3': 'mock',
|
|
228
|
+
* },
|
|
229
|
+
* }
|
|
230
|
+
*
|
|
231
|
+
* // Real TimeBack integration (requires env credentials)
|
|
232
|
+
* timeback: {
|
|
233
|
+
* timebackId: 'real-student-sourced-id',
|
|
234
|
+
* courses: {
|
|
235
|
+
* 'FastMath:3': 'real-course-id-g3',
|
|
236
|
+
* 'FastMath:4': 'real-course-id-g4',
|
|
237
|
+
* },
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export interface PlaycademyTimebackOptions {
|
|
242
|
+
/**
|
|
243
|
+
* TimeBack ID for the test user. Optional for mock testing (auto-generated).
|
|
244
|
+
* Required when testing against real TimeBack - use the student's sourcedId.
|
|
245
|
+
*/
|
|
246
|
+
timebackId?: string;
|
|
247
|
+
/**
|
|
248
|
+
* User role for testing. Defaults to 'student'.
|
|
249
|
+
* Use this to test parent/teacher views of your game.
|
|
250
|
+
*/
|
|
251
|
+
role?: 'student' | 'parent' | 'teacher' | 'administrator' | 'guardian';
|
|
252
|
+
/**
|
|
253
|
+
* Course enrollments mapping 'Subject:Grade' to 'mock' or real course ID.
|
|
254
|
+
* Only courses listed here will be enrolled - allows testing partial enrollment.
|
|
255
|
+
*/
|
|
256
|
+
courses: Record<string, 'mock' | string>;
|
|
257
|
+
}
|
|
210
258
|
/**
|
|
211
259
|
* Configuration options for the development shell wrapper
|
|
212
260
|
*
|
|
@@ -334,4 +382,21 @@ export interface PlaycademyPluginOptions {
|
|
|
334
382
|
* ```
|
|
335
383
|
*/
|
|
336
384
|
shell?: PlaycademyShellOptions;
|
|
385
|
+
/**
|
|
386
|
+
* TimeBack integration configuration.
|
|
387
|
+
*
|
|
388
|
+
* Configure mock or real TimeBack enrollments for local development.
|
|
389
|
+
* `timebackId` is auto-generated for mock testing.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* timeback: {
|
|
394
|
+
* courses: {
|
|
395
|
+
* 'FastMath:3': 'mock',
|
|
396
|
+
* 'FastMath:4': 'mock',
|
|
397
|
+
* },
|
|
398
|
+
* }
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
timeback?: PlaycademyTimebackOptions;
|
|
337
402
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"archiver": "^7.0.1",
|
|
23
23
|
"picocolors": "^1.1.1",
|
|
24
|
-
"playcademy": "0.14.
|
|
24
|
+
"playcademy": "0.14.25"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@inquirer/prompts": "^7.8.6",
|
|
28
|
-
"@playcademy/sandbox": "0.
|
|
28
|
+
"@playcademy/sandbox": "0.2.3",
|
|
29
29
|
"@types/archiver": "^6.0.3",
|
|
30
30
|
"@types/bun": "latest"
|
|
31
31
|
},
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mode switching functionality
|
|
3
|
-
* Handles toggling between platform and standalone modes
|
|
4
|
-
*/
|
|
5
|
-
import type { ModeSwitcherOptions } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* Toggle between platform and standalone modes
|
|
8
|
-
*/
|
|
9
|
-
export declare function toggleMode(options: ModeSwitcherOptions): Promise<void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandbox database recreation functionality
|
|
3
|
-
* Handles recreating the sandbox database on-demand
|
|
4
|
-
*/
|
|
5
|
-
import type { ResolvedConfig } from 'vite';
|
|
6
|
-
import type { PlatformModeOptions } from '../types';
|
|
7
|
-
export interface RecreateSandboxDatabaseOptions {
|
|
8
|
-
viteConfig: ResolvedConfig;
|
|
9
|
-
platformModeOptions: PlatformModeOptions;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Recreate the sandbox database
|
|
13
|
-
*/
|
|
14
|
-
export declare function recreateSandboxDatabase(options: RecreateSandboxDatabaseOptions): Promise<void>;
|