playcademy 0.28.1-beta.2 → 0.28.1-beta.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/dist/bucket.d.ts +8 -0
- package/dist/bucket.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/db.js +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.js +85 -14
- package/dist/runtime/dashboard-runtime/manifest.json +4 -4
- package/dist/runtime/game-runtime/index.js +40 -29
- package/dist/runtime/game-runtime/manifest.json +4 -4
- package/dist/templates/playcademy-env.d.ts.template +2 -1
- package/dist/utils.d.ts +8 -1
- package/dist/utils.js +5 -6
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/bucket.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GamePermission } from '@playcademy/constants';
|
|
1
2
|
import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/types/timeback';
|
|
2
3
|
import { Miniflare } from 'miniflare';
|
|
3
4
|
|
|
@@ -148,6 +149,13 @@ interface PlaycademyConfig {
|
|
|
148
149
|
description?: string;
|
|
149
150
|
/** Game emoji icon */
|
|
150
151
|
emoji?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Browser permissions to request for the game's iframe (e.g.
|
|
154
|
+
* `['microphone']`). Opt-in per game; only `microphone` and `camera` are
|
|
155
|
+
* delegated this way. Fullscreen, autoplay, and gamepad are granted to
|
|
156
|
+
* every game automatically.
|
|
157
|
+
*/
|
|
158
|
+
permissions?: GamePermission[];
|
|
151
159
|
/** Build command to run before deployment */
|
|
152
160
|
buildCommand?: string[];
|
|
153
161
|
/** Path to build output */
|
package/dist/bucket.js
CHANGED
|
@@ -44,7 +44,7 @@ var GAME_API_ROUTES_DIRECTORY = join2(GAME_SERVER_ROOT_DIRECTORY, "api");
|
|
|
44
44
|
// ../better-auth/package.json
|
|
45
45
|
var package_default = {
|
|
46
46
|
name: "@playcademy/better-auth",
|
|
47
|
-
version: "0.0.21-beta.
|
|
47
|
+
version: "0.0.21-beta.4",
|
|
48
48
|
type: "module",
|
|
49
49
|
exports: {
|
|
50
50
|
"./server": {
|
package/dist/cli.js
CHANGED
|
@@ -1207,7 +1207,7 @@ var SAMPLE_BUCKET_FILENAME = "bucket.ts";
|
|
|
1207
1207
|
// ../better-auth/package.json
|
|
1208
1208
|
var package_default = {
|
|
1209
1209
|
name: "@playcademy/better-auth",
|
|
1210
|
-
version: "0.0.21-beta.
|
|
1210
|
+
version: "0.0.21-beta.4",
|
|
1211
1211
|
type: "module",
|
|
1212
1212
|
exports: {
|
|
1213
1213
|
"./server": {
|
|
@@ -3009,7 +3009,7 @@ import { existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as re
|
|
|
3009
3009
|
import { join as join13 } from "node:path";
|
|
3010
3010
|
|
|
3011
3011
|
// src/version.ts
|
|
3012
|
-
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.
|
|
3012
|
+
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.4";
|
|
3013
3013
|
|
|
3014
3014
|
// src/lib/init/database.ts
|
|
3015
3015
|
var drizzleConfigTemplate = loadTemplateString("database/drizzle-config.ts");
|
package/dist/constants.js
CHANGED
package/dist/db.js
CHANGED
|
@@ -2335,7 +2335,7 @@ var GAME_API_ROUTES_DIRECTORY = join2(GAME_SERVER_ROOT_DIRECTORY, "api");
|
|
|
2335
2335
|
// ../better-auth/package.json
|
|
2336
2336
|
var package_default = {
|
|
2337
2337
|
name: "@playcademy/better-auth",
|
|
2338
|
-
version: "0.0.21-beta.
|
|
2338
|
+
version: "0.0.21-beta.4",
|
|
2339
2339
|
type: "module",
|
|
2340
2340
|
exports: {
|
|
2341
2341
|
"./server": {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiKeyRow } from '@playcademy/data/types';
|
|
2
2
|
import { UserInfo } from '@playcademy/types/user';
|
|
3
3
|
import { SchemaInfo } from '@playcademy/cloudflare';
|
|
4
|
+
import { GamePermission } from '@playcademy/constants';
|
|
4
5
|
import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/types/timeback';
|
|
5
6
|
export { ComponentConfig, ComponentResourceConfig, OrganizationConfig, ResourceConfig, TimebackCourseConfig, TimebackGrade, TimebackSourcedIds, TimebackSubject } from '@playcademy/types/timeback';
|
|
6
7
|
import { PlaycademyClient } from '@playcademy/sdk/internal';
|
|
@@ -434,6 +435,13 @@ interface PlaycademyConfig {
|
|
|
434
435
|
description?: string;
|
|
435
436
|
/** Game emoji icon */
|
|
436
437
|
emoji?: string;
|
|
438
|
+
/**
|
|
439
|
+
* Browser permissions to request for the game's iframe (e.g.
|
|
440
|
+
* `['microphone']`). Opt-in per game; only `microphone` and `camera` are
|
|
441
|
+
* delegated this way. Fullscreen, autoplay, and gamepad are granted to
|
|
442
|
+
* every game automatically.
|
|
443
|
+
*/
|
|
444
|
+
permissions?: GamePermission[];
|
|
437
445
|
/** Build command to run before deployment */
|
|
438
446
|
buildCommand?: string[];
|
|
439
447
|
/** Path to build output */
|
|
@@ -485,6 +493,8 @@ interface WorkerDeploymentBundle {
|
|
|
485
493
|
interface GameMetadata {
|
|
486
494
|
description?: string;
|
|
487
495
|
emoji?: string;
|
|
496
|
+
/** Browser permissions delegated to the game's iframe (opt-in per game). */
|
|
497
|
+
permissions?: GamePermission[];
|
|
488
498
|
[key: string]: unknown;
|
|
489
499
|
}
|
|
490
500
|
declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
@@ -1079,6 +1089,13 @@ interface DeployConfig {
|
|
|
1079
1089
|
description?: string;
|
|
1080
1090
|
/** Emoji icon for the project */
|
|
1081
1091
|
emoji?: string;
|
|
1092
|
+
/**
|
|
1093
|
+
* Browser permissions the game's iframe should be granted (e.g.
|
|
1094
|
+
* `['microphone']`). Opt-in per game; only `microphone` and `camera` are
|
|
1095
|
+
* delegated this way. Fullscreen, autoplay, and gamepad are granted to
|
|
1096
|
+
* every game automatically.
|
|
1097
|
+
*/
|
|
1098
|
+
permissions?: GamePermission[];
|
|
1082
1099
|
/** Path to the build directory or zip file */
|
|
1083
1100
|
buildPath?: string;
|
|
1084
1101
|
/** Game platform (defaults to 'web') */
|
|
@@ -1291,6 +1308,10 @@ interface ConfigDiff {
|
|
|
1291
1308
|
old: string | undefined;
|
|
1292
1309
|
new: string | undefined;
|
|
1293
1310
|
};
|
|
1311
|
+
permissions?: {
|
|
1312
|
+
old: string[] | undefined;
|
|
1313
|
+
new: string[] | undefined;
|
|
1314
|
+
};
|
|
1294
1315
|
gameType?: {
|
|
1295
1316
|
old: string;
|
|
1296
1317
|
new: string;
|
package/dist/index.js
CHANGED
|
@@ -2346,7 +2346,7 @@ var SAMPLE_BUCKET_FILENAME = "bucket.ts";
|
|
|
2346
2346
|
// ../better-auth/package.json
|
|
2347
2347
|
var package_default = {
|
|
2348
2348
|
name: "@playcademy/better-auth",
|
|
2349
|
-
version: "0.0.21-beta.
|
|
2349
|
+
version: "0.0.21-beta.4",
|
|
2350
2350
|
type: "module",
|
|
2351
2351
|
exports: {
|
|
2352
2352
|
"./server": {
|
|
@@ -2612,6 +2612,7 @@ var GAME_MEMBER_ROLES = {
|
|
|
2612
2612
|
OWNER: "owner",
|
|
2613
2613
|
COLLABORATOR: "collaborator"
|
|
2614
2614
|
};
|
|
2615
|
+
var GAME_PERMISSIONS = ["microphone", "camera"];
|
|
2615
2616
|
|
|
2616
2617
|
// ../constants/src/timeback.ts
|
|
2617
2618
|
var TIMEBACK_GRADES = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
|
|
@@ -4357,7 +4358,6 @@ function buildQueueHandlerCode(queueHandlers) {
|
|
|
4357
4358
|
...queueHandlers.map((handler, index4) => ` '${handler.key}': queueHandler${index4},`),
|
|
4358
4359
|
"}",
|
|
4359
4360
|
"",
|
|
4360
|
-
"registerQueueIngressRoute(app, __queueHandlers)",
|
|
4361
4361
|
"const __queueRouter = createQueueRouter(__queueHandlers)",
|
|
4362
4362
|
""
|
|
4363
4363
|
].join("\n");
|
|
@@ -5873,7 +5873,13 @@ function buildDeployGameMetadataPayload(config) {
|
|
|
5873
5873
|
gameType: "hosted",
|
|
5874
5874
|
metadata: {
|
|
5875
5875
|
...config.description !== void 0 && { description: config.description },
|
|
5876
|
-
...config.emoji !== void 0 && { emoji: config.emoji }
|
|
5876
|
+
...config.emoji !== void 0 && { emoji: config.emoji },
|
|
5877
|
+
// Empty and absent both mean "no permissions declared", so an empty
|
|
5878
|
+
// array is omitted rather than stored: it keeps the payload aligned
|
|
5879
|
+
// with the empty-is-absent rule the deploy diff uses (diff.ts), so a
|
|
5880
|
+
// game with `permissions: []` never drifts against a platform that
|
|
5881
|
+
// has no permissions key.
|
|
5882
|
+
...config.permissions !== void 0 && config.permissions.length > 0 && { permissions: config.permissions }
|
|
5877
5883
|
}
|
|
5878
5884
|
};
|
|
5879
5885
|
}
|
|
@@ -6390,7 +6396,7 @@ import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as re
|
|
|
6390
6396
|
import { join as join13 } from "node:path";
|
|
6391
6397
|
|
|
6392
6398
|
// src/version.ts
|
|
6393
|
-
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.
|
|
6399
|
+
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.4";
|
|
6394
6400
|
|
|
6395
6401
|
// src/lib/init/database.ts
|
|
6396
6402
|
var drizzleConfigTemplate = loadTemplateString("database/drizzle-config.ts");
|
|
@@ -13312,7 +13318,7 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
13312
13318
|
runtimeImports.push("registerHooks", "wrapHandler");
|
|
13313
13319
|
}
|
|
13314
13320
|
if (queueHandlers.length > 0) {
|
|
13315
|
-
runtimeImports.push("createQueueRouter"
|
|
13321
|
+
runtimeImports.push("createQueueRouter");
|
|
13316
13322
|
}
|
|
13317
13323
|
const importBlocks = [`import { ${runtimeImports.join(", ")} } from '@playcademy/game-runtime'`];
|
|
13318
13324
|
if (hasAuth) {
|
|
@@ -13332,7 +13338,8 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
13332
13338
|
}
|
|
13333
13339
|
const body = [
|
|
13334
13340
|
"// PLAYCADEMY_CONFIG is injected at bundle time via esbuild define",
|
|
13335
|
-
|
|
13341
|
+
buildQueueHandlerCode(queueHandlers),
|
|
13342
|
+
queueHandlers.length > 0 ? "const app = createBaseApp(PLAYCADEMY_CONFIG, __queueHandlers)" : "const app = createBaseApp(PLAYCADEMY_CONFIG)",
|
|
13336
13343
|
""
|
|
13337
13344
|
];
|
|
13338
13345
|
if (hasAuth) {
|
|
@@ -13348,7 +13355,6 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
13348
13355
|
buildCustomRouteModuleCode(customRoutes),
|
|
13349
13356
|
"registerCustomRouteModules(app, __customRoutes)",
|
|
13350
13357
|
"",
|
|
13351
|
-
buildQueueHandlerCode(queueHandlers),
|
|
13352
13358
|
"registerTerminalHandlers(app)",
|
|
13353
13359
|
""
|
|
13354
13360
|
);
|
|
@@ -21179,6 +21185,7 @@ function transformToDeployConfig(userConfig) {
|
|
|
21179
21185
|
displayName: userConfig.name,
|
|
21180
21186
|
description: userConfig.description,
|
|
21181
21187
|
emoji: userConfig.emoji,
|
|
21188
|
+
permissions: userConfig.permissions,
|
|
21182
21189
|
buildPath: userConfig.buildPath,
|
|
21183
21190
|
platform: userConfig.platform
|
|
21184
21191
|
};
|
|
@@ -21761,25 +21768,40 @@ var GAME_METADATA_DRIFT_LABELS = {
|
|
|
21761
21768
|
platform: "Platform",
|
|
21762
21769
|
metadataPrefix: "metadata."
|
|
21763
21770
|
};
|
|
21771
|
+
var RESOLVABLE_METADATA_KEYS = /* @__PURE__ */ new Set(["description", "emoji"]);
|
|
21772
|
+
function isResolvableDriftLabel(label) {
|
|
21773
|
+
if (label === GAME_METADATA_DRIFT_LABELS.displayName) {
|
|
21774
|
+
return true;
|
|
21775
|
+
}
|
|
21776
|
+
if (label === GAME_METADATA_DRIFT_LABELS.platform) {
|
|
21777
|
+
return true;
|
|
21778
|
+
}
|
|
21779
|
+
if (!label.startsWith(GAME_METADATA_DRIFT_LABELS.metadataPrefix)) {
|
|
21780
|
+
return false;
|
|
21781
|
+
}
|
|
21782
|
+
return RESOLVABLE_METADATA_KEYS.has(
|
|
21783
|
+
label.slice(GAME_METADATA_DRIFT_LABELS.metadataPrefix.length)
|
|
21784
|
+
);
|
|
21785
|
+
}
|
|
21764
21786
|
function metadataValuesEqual(a, b) {
|
|
21765
21787
|
if (Object.is(a, b)) {
|
|
21766
21788
|
return true;
|
|
21767
21789
|
}
|
|
21768
21790
|
if (typeof a === "object" && a !== null && typeof b === "object" && b !== null) {
|
|
21769
|
-
return JSON.stringify(
|
|
21791
|
+
return JSON.stringify(canonicalizeJson(a)) === JSON.stringify(canonicalizeJson(b));
|
|
21770
21792
|
}
|
|
21771
21793
|
return false;
|
|
21772
21794
|
}
|
|
21773
|
-
function
|
|
21795
|
+
function canonicalizeJson(value) {
|
|
21774
21796
|
if (value === null || typeof value !== "object") {
|
|
21775
21797
|
return value;
|
|
21776
21798
|
}
|
|
21777
21799
|
if (Array.isArray(value)) {
|
|
21778
|
-
return value.map(
|
|
21800
|
+
return value.map(canonicalizeJson).toSorted((x, y) => JSON.stringify(x) < JSON.stringify(y) ? -1 : 1);
|
|
21779
21801
|
}
|
|
21780
21802
|
const sorted = {};
|
|
21781
21803
|
for (const key of Object.keys(value).toSorted()) {
|
|
21782
|
-
sorted[key] =
|
|
21804
|
+
sorted[key] = canonicalizeJson(value[key]);
|
|
21783
21805
|
}
|
|
21784
21806
|
return sorted;
|
|
21785
21807
|
}
|
|
@@ -21826,6 +21848,23 @@ function skipsDeployGameDueToSecretsOnly(context2, plan) {
|
|
|
21826
21848
|
|
|
21827
21849
|
// src/lib/deploy/game/diff.ts
|
|
21828
21850
|
import { dim as dim8, green as green7, red as red4, yellow as yellow5 } from "colorette";
|
|
21851
|
+
function toPermissionList(value) {
|
|
21852
|
+
if (!Array.isArray(value)) {
|
|
21853
|
+
return void 0;
|
|
21854
|
+
}
|
|
21855
|
+
return value.filter((entry) => typeof entry === "string");
|
|
21856
|
+
}
|
|
21857
|
+
function formatPermissionList(value) {
|
|
21858
|
+
return value && value.length > 0 ? value.join(", ") : "(none)";
|
|
21859
|
+
}
|
|
21860
|
+
function permissionListsEqual(a, b) {
|
|
21861
|
+
const left = a ?? [];
|
|
21862
|
+
const right = b ?? [];
|
|
21863
|
+
if (left.length !== right.length) {
|
|
21864
|
+
return false;
|
|
21865
|
+
}
|
|
21866
|
+
return left.toSorted().join(",") === right.toSorted().join(",");
|
|
21867
|
+
}
|
|
21829
21868
|
function calculateConfigDiff(existingGame, newConfig) {
|
|
21830
21869
|
const diff = {};
|
|
21831
21870
|
if (newConfig.displayName && existingGame.displayName !== newConfig.displayName) {
|
|
@@ -21837,6 +21876,11 @@ function calculateConfigDiff(existingGame, newConfig) {
|
|
|
21837
21876
|
if (existingGame.metadata.description !== newConfig.description) {
|
|
21838
21877
|
diff.description = { old: existingGame.metadata.description, new: newConfig.description };
|
|
21839
21878
|
}
|
|
21879
|
+
const existingPermissions = toPermissionList(existingGame.metadata.permissions);
|
|
21880
|
+
const newPermissions = newConfig.permissions;
|
|
21881
|
+
if (!permissionListsEqual(existingPermissions, newPermissions)) {
|
|
21882
|
+
diff.permissions = { old: existingPermissions, new: newPermissions };
|
|
21883
|
+
}
|
|
21840
21884
|
if (newConfig.gameType && existingGame.gameType !== newConfig.gameType) {
|
|
21841
21885
|
diff.gameType = { old: existingGame.gameType, new: newConfig.gameType };
|
|
21842
21886
|
}
|
|
@@ -22110,7 +22154,10 @@ function displayIntegrationAndSecretsChanges(integrations, secrets, secretsChang
|
|
|
22110
22154
|
}
|
|
22111
22155
|
function displayConfigSection(diff, driftLabels) {
|
|
22112
22156
|
function driftHint(label) {
|
|
22113
|
-
|
|
22157
|
+
if (!driftLabels?.has(label) || !isResolvableDriftLabel(label)) {
|
|
22158
|
+
return "";
|
|
22159
|
+
}
|
|
22160
|
+
return ` ${red4("[differs from platform]")}`;
|
|
22114
22161
|
}
|
|
22115
22162
|
logger.bold("Config", 1);
|
|
22116
22163
|
if (diff.displayName) {
|
|
@@ -22134,6 +22181,13 @@ function displayConfigSection(diff, driftLabels) {
|
|
|
22134
22181
|
2
|
|
22135
22182
|
);
|
|
22136
22183
|
}
|
|
22184
|
+
if (diff.permissions) {
|
|
22185
|
+
logger.data(
|
|
22186
|
+
"Permissions",
|
|
22187
|
+
`${red4(formatPermissionList(diff.permissions.old))} \u2192 ${green7(formatPermissionList(diff.permissions.new))}${driftHint(`${GAME_METADATA_DRIFT_LABELS.metadataPrefix}permissions`)}`,
|
|
22188
|
+
2
|
|
22189
|
+
);
|
|
22190
|
+
}
|
|
22137
22191
|
logger.newLine();
|
|
22138
22192
|
}
|
|
22139
22193
|
function displayDeploymentDiff(options) {
|
|
@@ -22600,6 +22654,22 @@ async function validateDeployConfig(config) {
|
|
|
22600
22654
|
errors.push(result);
|
|
22601
22655
|
}
|
|
22602
22656
|
}
|
|
22657
|
+
if (config.permissions !== void 0) {
|
|
22658
|
+
if (!Array.isArray(config.permissions)) {
|
|
22659
|
+
errors.push(
|
|
22660
|
+
`permissions must be an array of ${GAME_PERMISSIONS.map((p) => `'${p}'`).join(" | ")}`
|
|
22661
|
+
);
|
|
22662
|
+
} else {
|
|
22663
|
+
const invalid = config.permissions.filter(
|
|
22664
|
+
(permission) => !GAME_PERMISSIONS.includes(permission)
|
|
22665
|
+
);
|
|
22666
|
+
if (invalid.length > 0) {
|
|
22667
|
+
errors.push(
|
|
22668
|
+
`permissions has unknown ${invalid.length === 1 ? "value" : "values"} ${invalid.map((p) => `'${String(p)}'`).join(", ")} (allowed: ${GAME_PERMISSIONS.map((p) => `'${p}'`).join(", ")})`
|
|
22669
|
+
);
|
|
22670
|
+
}
|
|
22671
|
+
}
|
|
22672
|
+
}
|
|
22603
22673
|
if (errors.length > 0) {
|
|
22604
22674
|
logger.error("Configuration validation failed:");
|
|
22605
22675
|
errors.forEach((error) => logger.error(`${error}`, 1));
|
|
@@ -23097,7 +23167,6 @@ async function promptGameMetadataDriftDecision(args) {
|
|
|
23097
23167
|
nonInteractiveHint: NON_INTERACTIVE_HINTS.GAME_METADATA_DRIFT
|
|
23098
23168
|
});
|
|
23099
23169
|
}
|
|
23100
|
-
var AUTO_RESOLVABLE_METADATA_KEYS = /* @__PURE__ */ new Set(["description", "emoji"]);
|
|
23101
23170
|
async function applyPlatformValuesToLocalConfig(args) {
|
|
23102
23171
|
const { context: context2, rows, remoteGame } = args;
|
|
23103
23172
|
if (!context2.configFileName) {
|
|
@@ -23158,7 +23227,7 @@ function classifyDriftRow(row, remoteGame, writeDisplayName) {
|
|
|
23158
23227
|
return { kind: "skip" };
|
|
23159
23228
|
}
|
|
23160
23229
|
const key = row.label.slice(GAME_METADATA_DRIFT_LABELS.metadataPrefix.length);
|
|
23161
|
-
if (!
|
|
23230
|
+
if (!RESOLVABLE_METADATA_KEYS.has(key)) {
|
|
23162
23231
|
return { kind: "unresolvable" };
|
|
23163
23232
|
}
|
|
23164
23233
|
const remoteValue = remoteGame.metadata?.[key];
|
|
@@ -28660,6 +28729,7 @@ export {
|
|
|
28660
28729
|
NonInteractivePromptError,
|
|
28661
28730
|
OPTIONAL_FIELDS,
|
|
28662
28731
|
REQUIRED_FIELDS,
|
|
28732
|
+
RESOLVABLE_METADATA_KEYS,
|
|
28663
28733
|
addEmailProvider,
|
|
28664
28734
|
addOAuthProvider,
|
|
28665
28735
|
addPlaycademySdk,
|
|
@@ -28919,6 +28989,7 @@ export {
|
|
|
28919
28989
|
isPluginConfigured,
|
|
28920
28990
|
isPushAdopted,
|
|
28921
28991
|
isRecord3 as isRecord,
|
|
28992
|
+
isResolvableDriftLabel,
|
|
28922
28993
|
isSchemaAdopted,
|
|
28923
28994
|
isStrategyExplicit,
|
|
28924
28995
|
isVitePluginInstalled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cliVersion": "0.28.1-beta.
|
|
3
|
-
"sdkVersion": "0.16.1-beta.
|
|
4
|
-
"runtimeBuildId": "
|
|
5
|
-
"inputFingerprint": "
|
|
2
|
+
"cliVersion": "0.28.1-beta.4",
|
|
3
|
+
"sdkVersion": "0.16.1-beta.4",
|
|
4
|
+
"runtimeBuildId": "0b303f7737b5",
|
|
5
|
+
"inputFingerprint": "0b303f7737b5afa41bd3b95ecc9825a9142d651a68e0a1017f25ef6005db378d",
|
|
6
6
|
"entry": "index.js"
|
|
7
7
|
}
|
|
@@ -6510,9 +6510,9 @@ var init_list = __esm({
|
|
|
6510
6510
|
// ../edge-play/src/game/lib/metadata.ts
|
|
6511
6511
|
function getRuntimeMetadata() {
|
|
6512
6512
|
return {
|
|
6513
|
-
cliVersion: true ? "0.28.1-beta.
|
|
6514
|
-
sdkVersion: true ? "0.16.1-beta.
|
|
6515
|
-
buildId: true ? "
|
|
6513
|
+
cliVersion: true ? "0.28.1-beta.4" : "0.0.0-dev",
|
|
6514
|
+
sdkVersion: true ? "0.16.1-beta.4" : "0.0.0-dev",
|
|
6515
|
+
buildId: true ? "0b303f7737b5" : "dev-source"
|
|
6516
6516
|
};
|
|
6517
6517
|
}
|
|
6518
6518
|
var init_metadata = __esm({
|
|
@@ -9446,18 +9446,15 @@ function registerEnvSetup(app, config) {
|
|
|
9446
9446
|
});
|
|
9447
9447
|
}
|
|
9448
9448
|
function registerSdkInit(app, config) {
|
|
9449
|
-
let
|
|
9449
|
+
let sdkClient = null;
|
|
9450
9450
|
app.use("*", async (c, next) => {
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
}
|
|
9459
|
-
const sharedClient = await sdkPromise;
|
|
9460
|
-
const sdk = sharedClient.forRequest({
|
|
9451
|
+
sdkClient ??= await PlaycademyClient.init({
|
|
9452
|
+
apiKey: c.env.PLAYCADEMY_API_KEY,
|
|
9453
|
+
gameId: c.env.GAME_ID,
|
|
9454
|
+
baseUrl: c.env.PLAYCADEMY_BASE_URL,
|
|
9455
|
+
config
|
|
9456
|
+
});
|
|
9457
|
+
const sdk = sdkClient.forRequest({
|
|
9461
9458
|
launchId: c.req.header("x-playcademy-launch-id"),
|
|
9462
9459
|
gameOrigin: new URL(c.req.url).origin
|
|
9463
9460
|
});
|
|
@@ -11076,6 +11073,11 @@ function toMessageBatch(payload, fallbackQueueName) {
|
|
|
11076
11073
|
const payloadMessages = Array.isArray(payloadRecord?.messages) ? payloadRecord.messages : [];
|
|
11077
11074
|
const queueName = typeof payloadRecord?.queue === "string" ? payloadRecord.queue : fallbackQueueName;
|
|
11078
11075
|
const decisions = Array.from({ length: payloadMessages.length }, () => null);
|
|
11076
|
+
function decide(index, decision) {
|
|
11077
|
+
if (decisions[index] === null) {
|
|
11078
|
+
decisions[index] = decision;
|
|
11079
|
+
}
|
|
11080
|
+
}
|
|
11079
11081
|
const batch = {
|
|
11080
11082
|
queue: queueName,
|
|
11081
11083
|
messages: payloadMessages.map((message2, index) => {
|
|
@@ -11085,18 +11087,23 @@ function toMessageBatch(payload, fallbackQueueName) {
|
|
|
11085
11087
|
timestamp: msg.timestamp ? new Date(String(msg.timestamp)) : /* @__PURE__ */ new Date(),
|
|
11086
11088
|
body: msg.body,
|
|
11087
11089
|
attempts: Number(msg.attempts ?? 1),
|
|
11088
|
-
ack: () =>
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
},
|
|
11093
|
-
retry: () => {
|
|
11094
|
-
if (decisions[index] === null) {
|
|
11095
|
-
decisions[index] = "retry";
|
|
11096
|
-
}
|
|
11097
|
-
}
|
|
11090
|
+
ack: () => decide(index, "ack"),
|
|
11091
|
+
// Retry options (delaySeconds) have no channel in the
|
|
11092
|
+
// decisions protocol yet and are ignored.
|
|
11093
|
+
retry: () => decide(index, "retry")
|
|
11098
11094
|
};
|
|
11099
|
-
})
|
|
11095
|
+
}),
|
|
11096
|
+
// First decision wins per message, matching the per-message methods.
|
|
11097
|
+
ackAll: () => {
|
|
11098
|
+
for (let index = 0; index < decisions.length; index += 1) {
|
|
11099
|
+
decide(index, "ack");
|
|
11100
|
+
}
|
|
11101
|
+
},
|
|
11102
|
+
retryAll: () => {
|
|
11103
|
+
for (let index = 0; index < decisions.length; index += 1) {
|
|
11104
|
+
decide(index, "retry");
|
|
11105
|
+
}
|
|
11106
|
+
}
|
|
11100
11107
|
};
|
|
11101
11108
|
return {
|
|
11102
11109
|
batch,
|
|
@@ -11105,7 +11112,9 @@ function toMessageBatch(payload, fallbackQueueName) {
|
|
|
11105
11112
|
}
|
|
11106
11113
|
function registerQueueIngressRoute(app, queueHandlers) {
|
|
11107
11114
|
app.post("/__playcademy/queue/:name", async (c) => {
|
|
11108
|
-
const
|
|
11115
|
+
const env = prepareEnv(c.env);
|
|
11116
|
+
delete env.SELF;
|
|
11117
|
+
const expectedSecret = env.QUEUE_INGRESS_SECRET;
|
|
11109
11118
|
if (expectedSecret) {
|
|
11110
11119
|
const provided = c.req.header(QUEUE_INGRESS_AUTH_HEADER);
|
|
11111
11120
|
if (provided !== expectedSecret) {
|
|
@@ -11119,7 +11128,7 @@ function registerQueueIngressRoute(app, queueHandlers) {
|
|
|
11119
11128
|
}
|
|
11120
11129
|
const payload = await c.req.json().catch(() => null);
|
|
11121
11130
|
const { batch, decisions } = toMessageBatch(payload, name);
|
|
11122
|
-
await handler.queue(batch,
|
|
11131
|
+
await handler.queue(batch, env, c.executionCtx);
|
|
11123
11132
|
return c.json({ ok: true, decisions });
|
|
11124
11133
|
});
|
|
11125
11134
|
}
|
|
@@ -11211,10 +11220,13 @@ function wrapHandler(baseHandler, createHandler) {
|
|
|
11211
11220
|
}
|
|
11212
11221
|
|
|
11213
11222
|
// ../edge-play/src/game/entry.ts
|
|
11214
|
-
function createBaseApp(config) {
|
|
11223
|
+
function createBaseApp(config, queueHandlers) {
|
|
11215
11224
|
setupProcessGlobal();
|
|
11216
11225
|
const app = new Hono2();
|
|
11217
11226
|
registerBodyDisposal(app);
|
|
11227
|
+
if (queueHandlers) {
|
|
11228
|
+
registerQueueIngressRoute(app, queueHandlers);
|
|
11229
|
+
}
|
|
11218
11230
|
registerCors(app);
|
|
11219
11231
|
registerEnvSetup(app, config);
|
|
11220
11232
|
registerSdkInit(app, config);
|
|
@@ -11237,7 +11249,6 @@ export {
|
|
|
11237
11249
|
registerCustomRouteModules,
|
|
11238
11250
|
registerHooks,
|
|
11239
11251
|
registerMetricsRoute,
|
|
11240
|
-
registerQueueIngressRoute,
|
|
11241
11252
|
registerTerminalHandlers,
|
|
11242
11253
|
wrapHandler
|
|
11243
11254
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cliVersion": "0.28.1-beta.
|
|
3
|
-
"sdkVersion": "0.16.1-beta.
|
|
4
|
-
"runtimeBuildId": "
|
|
5
|
-
"inputFingerprint": "
|
|
2
|
+
"cliVersion": "0.28.1-beta.4",
|
|
3
|
+
"sdkVersion": "0.16.1-beta.4",
|
|
4
|
+
"runtimeBuildId": "0b303f7737b5",
|
|
5
|
+
"inputFingerprint": "0b303f7737b5afa41bd3b95ecc9825a9142d651a68e0a1017f25ef6005db378d",
|
|
6
6
|
"entry": "index.js"
|
|
7
7
|
}
|
|
@@ -32,7 +32,8 @@ declare global {
|
|
|
32
32
|
type QueueHandler = {
|
|
33
33
|
queue(
|
|
34
34
|
batch: MessageBatch<unknown>,
|
|
35
|
-
|
|
35
|
+
/** No SELF loopback: queue deliveries have no originating request. */
|
|
36
|
+
env: Omit<PlaycademyEnv, 'SELF'>,
|
|
36
37
|
ctx: ExecutionContext,
|
|
37
38
|
): Promise<void> | void
|
|
38
39
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { GamePermission, DashboardUserRole } from '@playcademy/constants';
|
|
1
2
|
import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/types/timeback';
|
|
2
3
|
import { Miniflare } from 'miniflare';
|
|
3
4
|
import * as chokidar from 'chokidar';
|
|
4
|
-
import { DashboardUserRole } from '@playcademy/constants';
|
|
5
5
|
import { PackageManager } from '@playcademy/utils/package-manager';
|
|
6
6
|
import * as esbuild from 'esbuild';
|
|
7
7
|
|
|
@@ -152,6 +152,13 @@ interface PlaycademyConfig {
|
|
|
152
152
|
description?: string;
|
|
153
153
|
/** Game emoji icon */
|
|
154
154
|
emoji?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Browser permissions to request for the game's iframe (e.g.
|
|
157
|
+
* `['microphone']`). Opt-in per game; only `microphone` and `camera` are
|
|
158
|
+
* delegated this way. Fullscreen, autoplay, and gamepad are granted to
|
|
159
|
+
* every game automatically.
|
|
160
|
+
*/
|
|
161
|
+
permissions?: GamePermission[];
|
|
155
162
|
/** Build command to run before deployment */
|
|
156
163
|
buildCommand?: string[];
|
|
157
164
|
/** Path to build output */
|
package/dist/utils.js
CHANGED
|
@@ -383,7 +383,7 @@ var DASHBOARD_API_ROUTES_DIRECTORY = "api";
|
|
|
383
383
|
// ../better-auth/package.json
|
|
384
384
|
var package_default = {
|
|
385
385
|
name: "@playcademy/better-auth",
|
|
386
|
-
version: "0.0.21-beta.
|
|
386
|
+
version: "0.0.21-beta.4",
|
|
387
387
|
type: "module",
|
|
388
388
|
exports: {
|
|
389
389
|
"./server": {
|
|
@@ -1672,7 +1672,6 @@ function buildQueueHandlerCode(queueHandlers) {
|
|
|
1672
1672
|
...queueHandlers.map((handler, index) => ` '${handler.key}': queueHandler${index},`),
|
|
1673
1673
|
"}",
|
|
1674
1674
|
"",
|
|
1675
|
-
"registerQueueIngressRoute(app, __queueHandlers)",
|
|
1676
1675
|
"const __queueRouter = createQueueRouter(__queueHandlers)",
|
|
1677
1676
|
""
|
|
1678
1677
|
].join("\n");
|
|
@@ -2795,7 +2794,7 @@ import { existsSync as existsSync9, mkdirSync as mkdirSync2, writeFileSync as wr
|
|
|
2795
2794
|
import { dirname as dirname4, join as join14 } from "node:path";
|
|
2796
2795
|
|
|
2797
2796
|
// src/version.ts
|
|
2798
|
-
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.
|
|
2797
|
+
var cliVersion = false ? "0.0.0-dev" : "0.28.1-beta.4";
|
|
2799
2798
|
|
|
2800
2799
|
// src/lib/build/binary-resource.ts
|
|
2801
2800
|
function writeFileTree(baseDir, files) {
|
|
@@ -5630,7 +5629,7 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
5630
5629
|
runtimeImports.push("registerHooks", "wrapHandler");
|
|
5631
5630
|
}
|
|
5632
5631
|
if (queueHandlers.length > 0) {
|
|
5633
|
-
runtimeImports.push("createQueueRouter"
|
|
5632
|
+
runtimeImports.push("createQueueRouter");
|
|
5634
5633
|
}
|
|
5635
5634
|
const importBlocks = [`import { ${runtimeImports.join(", ")} } from '@playcademy/game-runtime'`];
|
|
5636
5635
|
if (hasAuth) {
|
|
@@ -5650,7 +5649,8 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
5650
5649
|
}
|
|
5651
5650
|
const body = [
|
|
5652
5651
|
"// PLAYCADEMY_CONFIG is injected at bundle time via esbuild define",
|
|
5653
|
-
|
|
5652
|
+
buildQueueHandlerCode(queueHandlers),
|
|
5653
|
+
queueHandlers.length > 0 ? "const app = createBaseApp(PLAYCADEMY_CONFIG, __queueHandlers)" : "const app = createBaseApp(PLAYCADEMY_CONFIG)",
|
|
5654
5654
|
""
|
|
5655
5655
|
];
|
|
5656
5656
|
if (hasAuth) {
|
|
@@ -5666,7 +5666,6 @@ function generateGameEntryCode(customRoutes, customRoutesDir, queueHandlers, opt
|
|
|
5666
5666
|
buildCustomRouteModuleCode(customRoutes),
|
|
5667
5667
|
"registerCustomRouteModules(app, __customRoutes)",
|
|
5668
5668
|
"",
|
|
5669
|
-
buildQueueHandlerCode(queueHandlers),
|
|
5670
5669
|
"registerTerminalHandlers(app)",
|
|
5671
5670
|
""
|
|
5672
5671
|
);
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playcademy",
|
|
3
|
-
"version": "0.28.1-beta.
|
|
3
|
+
"version": "0.28.1-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@inquirer/prompts": "^7.8.6",
|
|
58
|
-
"@playcademy/sdk": "0.16.1-beta.
|
|
58
|
+
"@playcademy/sdk": "0.16.1-beta.4",
|
|
59
59
|
"chokidar": "^4.0.3",
|
|
60
60
|
"colorette": "^2.0.20",
|
|
61
61
|
"commander": "^14.0.1",
|