@playcademy/sdk 0.5.0 → 0.6.0-beta.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/dist/index.d.ts +1425 -1308
- package/dist/index.js +118 -12
- package/dist/internal.d.ts +68 -1
- package/dist/internal.js +115 -25
- package/dist/types.d.ts +506 -403
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var MessageEvents;
|
|
|
25
25
|
MessageEvents2["TELEMETRY"] = "PLAYCADEMY_TELEMETRY";
|
|
26
26
|
MessageEvents2["KEY_EVENT"] = "PLAYCADEMY_KEY_EVENT";
|
|
27
27
|
MessageEvents2["DISPLAY_ALERT"] = "PLAYCADEMY_DISPLAY_ALERT";
|
|
28
|
+
MessageEvents2["DEMO_END"] = "PLAYCADEMY_DEMO_END";
|
|
28
29
|
MessageEvents2["AUTH_STATE_CHANGE"] = "PLAYCADEMY_AUTH_STATE_CHANGE";
|
|
29
30
|
MessageEvents2["AUTH_CALLBACK"] = "PLAYCADEMY_AUTH_CALLBACK";
|
|
30
31
|
})(MessageEvents ||= {});
|
|
@@ -84,7 +85,8 @@ class PlaycademyMessaging {
|
|
|
84
85
|
"PLAYCADEMY_EXIT" /* EXIT */,
|
|
85
86
|
"PLAYCADEMY_TELEMETRY" /* TELEMETRY */,
|
|
86
87
|
"PLAYCADEMY_KEY_EVENT" /* KEY_EVENT */,
|
|
87
|
-
"PLAYCADEMY_DISPLAY_ALERT" /* DISPLAY_ALERT
|
|
88
|
+
"PLAYCADEMY_DISPLAY_ALERT" /* DISPLAY_ALERT */,
|
|
89
|
+
"PLAYCADEMY_DEMO_END" /* DEMO_END */
|
|
88
90
|
];
|
|
89
91
|
const shouldUsePostMessage = isIframe && iframeToParentEvents.includes(eventType);
|
|
90
92
|
return {
|
|
@@ -185,7 +187,8 @@ function createStandaloneConfig() {
|
|
|
185
187
|
gameUrl: globalThis.location.origin,
|
|
186
188
|
token: "mock-game-token-for-local-dev",
|
|
187
189
|
gameId: "mock-game-id-from-template",
|
|
188
|
-
realtimeUrl: undefined
|
|
190
|
+
realtimeUrl: undefined,
|
|
191
|
+
mode: "standalone"
|
|
189
192
|
};
|
|
190
193
|
globalThis.PLAYCADEMY = mockConfig;
|
|
191
194
|
return mockConfig;
|
|
@@ -203,6 +206,7 @@ async function init(options) {
|
|
|
203
206
|
gameUrl: config.gameUrl,
|
|
204
207
|
token: config.token,
|
|
205
208
|
gameId: config.gameId,
|
|
209
|
+
mode: config.mode,
|
|
206
210
|
autoStartSession: globalThis.self !== window.top,
|
|
207
211
|
onDisconnect: options?.onDisconnect,
|
|
208
212
|
enableConnectionMonitoring: options?.enableConnectionMonitoring
|
|
@@ -850,7 +854,12 @@ async function login2(client, options) {
|
|
|
850
854
|
// src/namespaces/game/identity.ts
|
|
851
855
|
function createIdentityNamespace(client) {
|
|
852
856
|
return {
|
|
853
|
-
connect: (options) =>
|
|
857
|
+
connect: (options) => {
|
|
858
|
+
if (client.mode === "demo") {
|
|
859
|
+
throw new PlaycademyError("identity.connect() is not available in demo mode. Use platform or standalone mode for OAuth flows.");
|
|
860
|
+
}
|
|
861
|
+
return login2(client, options);
|
|
862
|
+
},
|
|
854
863
|
_getContext: () => ({
|
|
855
864
|
isInIframe: client["authContext"]?.isInIframe ?? false
|
|
856
865
|
})
|
|
@@ -1050,6 +1059,42 @@ function createBackendNamespace(client) {
|
|
|
1050
1059
|
}
|
|
1051
1060
|
};
|
|
1052
1061
|
}
|
|
1062
|
+
// src/namespaces/game/guard.ts
|
|
1063
|
+
function assertPlatformMode(client, operation) {
|
|
1064
|
+
if (client.mode !== "platform") {
|
|
1065
|
+
throw new PlaycademyError(`${operation} requires platform mode (current: ${client.mode}). Check client.mode before calling.`);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
function assertDemoMode(client, operation) {
|
|
1069
|
+
if (client.mode !== "demo") {
|
|
1070
|
+
throw new PlaycademyError(`${operation} requires demo mode (current: ${client.mode}). Check client.mode before calling.`);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// src/namespaces/game/demo.ts
|
|
1075
|
+
function createDemoNamespace(client) {
|
|
1076
|
+
return {
|
|
1077
|
+
profile: {
|
|
1078
|
+
get: async () => {
|
|
1079
|
+
assertDemoMode(client, "demo.profile.get()");
|
|
1080
|
+
return client["request"]("/users/demo-profile", "GET");
|
|
1081
|
+
},
|
|
1082
|
+
update: async (updates) => {
|
|
1083
|
+
assertDemoMode(client, "demo.profile.update()");
|
|
1084
|
+
return client["request"]("/users/demo-profile", "PATCH", {
|
|
1085
|
+
body: updates
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
},
|
|
1089
|
+
end: (score, options) => {
|
|
1090
|
+
assertDemoMode(client, "demo.end()");
|
|
1091
|
+
messaging.send("PLAYCADEMY_DEMO_END" /* DEMO_END */, {
|
|
1092
|
+
score,
|
|
1093
|
+
...options
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1053
1098
|
// src/core/cache/permanent-cache.ts
|
|
1054
1099
|
function createPermanentCache(keyPrefix) {
|
|
1055
1100
|
const cache = new Map;
|
|
@@ -1112,10 +1157,17 @@ function createUsersNamespace(client) {
|
|
|
1112
1157
|
});
|
|
1113
1158
|
}
|
|
1114
1159
|
return {
|
|
1115
|
-
me: async () =>
|
|
1160
|
+
me: async () => {
|
|
1161
|
+
assertPlatformMode(client, "users.me()");
|
|
1162
|
+
return client["request"]("/users/me", "GET");
|
|
1163
|
+
},
|
|
1116
1164
|
inventory: {
|
|
1117
|
-
get: async () =>
|
|
1165
|
+
get: async () => {
|
|
1166
|
+
assertPlatformMode(client, "users.inventory.get()");
|
|
1167
|
+
return client["request"](`/inventory`, "GET");
|
|
1168
|
+
},
|
|
1118
1169
|
add: async (identifier, qty) => {
|
|
1170
|
+
assertPlatformMode(client, "users.inventory.add()");
|
|
1119
1171
|
const itemId = await resolveItemId(identifier);
|
|
1120
1172
|
const res = await client["request"](`/inventory/add`, "POST", { body: { itemId, qty } });
|
|
1121
1173
|
client["emit"]("inventoryChange", {
|
|
@@ -1126,6 +1178,7 @@ function createUsersNamespace(client) {
|
|
|
1126
1178
|
return res;
|
|
1127
1179
|
},
|
|
1128
1180
|
remove: async (identifier, qty) => {
|
|
1181
|
+
assertPlatformMode(client, "users.inventory.remove()");
|
|
1129
1182
|
const itemId = await resolveItemId(identifier);
|
|
1130
1183
|
const res = await client["request"](`/inventory/remove`, "POST", { body: { itemId, qty } });
|
|
1131
1184
|
client["emit"]("inventoryChange", {
|
|
@@ -1136,12 +1189,14 @@ function createUsersNamespace(client) {
|
|
|
1136
1189
|
return res;
|
|
1137
1190
|
},
|
|
1138
1191
|
quantity: async (identifier) => {
|
|
1192
|
+
assertPlatformMode(client, "users.inventory.quantity()");
|
|
1139
1193
|
const itemId = await resolveItemId(identifier);
|
|
1140
1194
|
const inventory = await client["request"](`/inventory`, "GET");
|
|
1141
1195
|
const item = inventory.find((inv) => inv.item?.id === itemId);
|
|
1142
1196
|
return item?.quantity ?? 0;
|
|
1143
1197
|
},
|
|
1144
1198
|
has: async (identifier, minQuantity = 1) => {
|
|
1199
|
+
assertPlatformMode(client, "users.inventory.has()");
|
|
1145
1200
|
const itemId = await resolveItemId(identifier);
|
|
1146
1201
|
const inventory = await client["request"](`/inventory`, "GET");
|
|
1147
1202
|
const item = inventory.find((inv) => inv.item?.id === itemId);
|
|
@@ -1315,11 +1370,13 @@ function createCreditsNamespace(client) {
|
|
|
1315
1370
|
}
|
|
1316
1371
|
return {
|
|
1317
1372
|
balance: async () => {
|
|
1373
|
+
assertPlatformMode(client, "credits.balance()");
|
|
1318
1374
|
const inventory = await client["request"]("/inventory", "GET");
|
|
1319
1375
|
const primaryCurrencyInventoryItem = inventory.find((item) => item.item?.slug === CURRENCIES.PRIMARY);
|
|
1320
1376
|
return primaryCurrencyInventoryItem?.quantity ?? 0;
|
|
1321
1377
|
},
|
|
1322
1378
|
add: async (amount) => {
|
|
1379
|
+
assertPlatformMode(client, "credits.add()");
|
|
1323
1380
|
if (amount <= 0) {
|
|
1324
1381
|
throw new Error("Amount must be positive");
|
|
1325
1382
|
}
|
|
@@ -1338,6 +1395,7 @@ function createCreditsNamespace(client) {
|
|
|
1338
1395
|
return result.newTotal;
|
|
1339
1396
|
},
|
|
1340
1397
|
spend: async (amount) => {
|
|
1398
|
+
assertPlatformMode(client, "credits.spend()");
|
|
1341
1399
|
if (amount <= 0) {
|
|
1342
1400
|
throw new Error("Amount must be positive");
|
|
1343
1401
|
}
|
|
@@ -1360,12 +1418,15 @@ function createCreditsNamespace(client) {
|
|
|
1360
1418
|
// src/namespaces/game/scores.ts
|
|
1361
1419
|
function createScoresNamespace(client) {
|
|
1362
1420
|
return {
|
|
1363
|
-
submit: async (
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1421
|
+
submit: async (score, metadata) => {
|
|
1422
|
+
const gameId = client["_ensureGameId"]();
|
|
1423
|
+
return client["request"](`/games/${gameId}/scores`, "POST", {
|
|
1424
|
+
body: {
|
|
1425
|
+
score,
|
|
1426
|
+
metadata
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1369
1430
|
};
|
|
1370
1431
|
}
|
|
1371
1432
|
// src/namespaces/game/realtime.ts
|
|
@@ -1373,6 +1434,7 @@ function createRealtimeNamespace(client) {
|
|
|
1373
1434
|
return {
|
|
1374
1435
|
token: {
|
|
1375
1436
|
get: async () => {
|
|
1437
|
+
assertPlatformMode(client, "realtime.token.get()");
|
|
1376
1438
|
const endpoint = client["gameId"] ? `/games/${client["gameId"]}/realtime/token` : "/realtime/token";
|
|
1377
1439
|
return client["request"](endpoint, "POST");
|
|
1378
1440
|
}
|
|
@@ -1826,6 +1888,7 @@ function createTimebackNamespace(client) {
|
|
|
1826
1888
|
}
|
|
1827
1889
|
return {
|
|
1828
1890
|
get user() {
|
|
1891
|
+
assertPlatformMode(client, "timeback.user");
|
|
1829
1892
|
return {
|
|
1830
1893
|
get id() {
|
|
1831
1894
|
return getTimeback()?.id;
|
|
@@ -1898,17 +1961,56 @@ function createTimebackNamespace(client) {
|
|
|
1898
1961
|
};
|
|
1899
1962
|
},
|
|
1900
1963
|
startActivity: (metadata, options) => {
|
|
1964
|
+
assertPlatformMode(client, "timeback.startActivity()");
|
|
1901
1965
|
activityTracker.startActivity(metadata, options);
|
|
1902
1966
|
},
|
|
1903
1967
|
pauseActivity: () => {
|
|
1968
|
+
assertPlatformMode(client, "timeback.pauseActivity()");
|
|
1904
1969
|
activityTracker.pauseActivity();
|
|
1905
1970
|
},
|
|
1906
1971
|
resumeActivity: () => {
|
|
1972
|
+
assertPlatformMode(client, "timeback.resumeActivity()");
|
|
1907
1973
|
activityTracker.resumeActivity();
|
|
1908
1974
|
},
|
|
1909
|
-
endActivity: async (data) =>
|
|
1975
|
+
endActivity: async (data) => {
|
|
1976
|
+
assertPlatformMode(client, "timeback.endActivity()");
|
|
1977
|
+
return activityTracker.endActivity(data);
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
// src/namespaces/platform/leaderboard.ts
|
|
1982
|
+
async function fetchInternalLeaderboardEntries(client, options) {
|
|
1983
|
+
const params = new URLSearchParams({
|
|
1984
|
+
timeframe: options?.timeframe || "all_time",
|
|
1985
|
+
limit: String(options?.limit || 10),
|
|
1986
|
+
offset: String(options?.offset || 0)
|
|
1987
|
+
});
|
|
1988
|
+
if (options?.gameId) {
|
|
1989
|
+
params.append("gameId", options.gameId);
|
|
1990
|
+
}
|
|
1991
|
+
return client["request"](`/leaderboard?${params}`, "GET");
|
|
1992
|
+
}
|
|
1993
|
+
async function fetchPublicLeaderboardEntries(client, options) {
|
|
1994
|
+
const params = new URLSearchParams({
|
|
1995
|
+
timeframe: options?.timeframe || "all_time",
|
|
1996
|
+
limit: String(options?.limit || 10),
|
|
1997
|
+
offset: String(options?.offset || 0)
|
|
1998
|
+
});
|
|
1999
|
+
params.append("gameId", options?.gameId || client["_ensureGameId"]());
|
|
2000
|
+
return client["request"](`/leaderboard?${params}`, "GET");
|
|
2001
|
+
}
|
|
2002
|
+
function createLeaderboardNamespace(client) {
|
|
2003
|
+
return {
|
|
2004
|
+
fetch: async (options) => fetchInternalLeaderboardEntries(client, options),
|
|
2005
|
+
getUserRank: async (gameId, userId) => client["request"](`/games/${gameId}/users/${userId}/rank`, "GET")
|
|
1910
2006
|
};
|
|
1911
2007
|
}
|
|
2008
|
+
function createLeaderboardFetchNamespace(client) {
|
|
2009
|
+
return {
|
|
2010
|
+
fetch: async (options) => fetchPublicLeaderboardEntries(client, options)
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1912
2014
|
// src/core/auth/strategies.ts
|
|
1913
2015
|
class ApiKeyAuth {
|
|
1914
2016
|
apiKey;
|
|
@@ -2357,6 +2459,7 @@ async function request({
|
|
|
2357
2459
|
class PlaycademyBaseClient {
|
|
2358
2460
|
baseUrl;
|
|
2359
2461
|
gameUrl;
|
|
2462
|
+
mode;
|
|
2360
2463
|
authStrategy;
|
|
2361
2464
|
gameId;
|
|
2362
2465
|
config;
|
|
@@ -2373,6 +2476,7 @@ class PlaycademyBaseClient {
|
|
|
2373
2476
|
constructor(config) {
|
|
2374
2477
|
this.baseUrl = config?.baseUrl?.endsWith("/api") ? config.baseUrl : `${config?.baseUrl}/api`;
|
|
2375
2478
|
this.gameUrl = config?.gameUrl;
|
|
2479
|
+
this.mode = config?.mode ?? "platform";
|
|
2376
2480
|
this.gameId = config?.gameId;
|
|
2377
2481
|
this.launchId = config?.launchId ?? undefined;
|
|
2378
2482
|
this.config = config || {};
|
|
@@ -2551,6 +2655,8 @@ class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
2551
2655
|
timeback = createTimebackNamespace(this);
|
|
2552
2656
|
credits = createCreditsNamespace(this);
|
|
2553
2657
|
scores = createScoresNamespace(this);
|
|
2658
|
+
leaderboard = createLeaderboardFetchNamespace(this);
|
|
2659
|
+
demo = createDemoNamespace(this);
|
|
2554
2660
|
realtime = createRealtimeNamespace(this);
|
|
2555
2661
|
backend = createBackendNamespace(this);
|
|
2556
2662
|
static init = init;
|
package/dist/internal.d.ts
CHANGED
|
@@ -1150,6 +1150,23 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
1150
1150
|
identity: undefined;
|
|
1151
1151
|
generated: undefined;
|
|
1152
1152
|
}, {}, {}>;
|
|
1153
|
+
isAnonymous: drizzle_orm_pg_core.PgColumn<{
|
|
1154
|
+
name: "is_anonymous";
|
|
1155
|
+
tableName: "user";
|
|
1156
|
+
dataType: "boolean";
|
|
1157
|
+
columnType: "PgBoolean";
|
|
1158
|
+
data: boolean;
|
|
1159
|
+
driverParam: boolean;
|
|
1160
|
+
notNull: true;
|
|
1161
|
+
hasDefault: true;
|
|
1162
|
+
isPrimaryKey: false;
|
|
1163
|
+
isAutoincrement: false;
|
|
1164
|
+
hasRuntimeDefault: false;
|
|
1165
|
+
enumValues: undefined;
|
|
1166
|
+
baseColumn: never;
|
|
1167
|
+
identity: undefined;
|
|
1168
|
+
generated: undefined;
|
|
1169
|
+
}, {}, {}>;
|
|
1153
1170
|
timebackId: drizzle_orm_pg_core.PgColumn<{
|
|
1154
1171
|
name: "timeback_id";
|
|
1155
1172
|
tableName: "user";
|
|
@@ -5050,6 +5067,7 @@ interface AuthStrategy {
|
|
|
5050
5067
|
declare abstract class PlaycademyBaseClient {
|
|
5051
5068
|
baseUrl: string;
|
|
5052
5069
|
gameUrl?: string;
|
|
5070
|
+
mode: PlaycademyMode;
|
|
5053
5071
|
protected authStrategy: AuthStrategy;
|
|
5054
5072
|
protected gameId?: string;
|
|
5055
5073
|
protected config: Partial<ClientConfig>;
|
|
@@ -5454,6 +5472,15 @@ declare enum MessageEvents {
|
|
|
5454
5472
|
* - `options`: `{ type?: 'info' | 'warning' | 'error', duration?: number }`
|
|
5455
5473
|
*/
|
|
5456
5474
|
DISPLAY_ALERT = "PLAYCADEMY_DISPLAY_ALERT",
|
|
5475
|
+
/**
|
|
5476
|
+
* Game signals that demo mode has ended.
|
|
5477
|
+
* Sent when a demo experience reaches its CTA/upgrade boundary.
|
|
5478
|
+
* Payload:
|
|
5479
|
+
* - `score?`: number
|
|
5480
|
+
* - `durationMs?`: number
|
|
5481
|
+
* - `metadata?`: `Record<string, unknown>`
|
|
5482
|
+
*/
|
|
5483
|
+
DEMO_END = "PLAYCADEMY_DEMO_END",
|
|
5457
5484
|
/**
|
|
5458
5485
|
* Notifies about authentication state changes.
|
|
5459
5486
|
* Can be sent in both directions depending on auth flow.
|
|
@@ -5521,6 +5548,8 @@ interface MessageEventMap {
|
|
|
5521
5548
|
[MessageEvents.KEY_EVENT]: KeyEventPayload;
|
|
5522
5549
|
/** Display alert request from game */
|
|
5523
5550
|
[MessageEvents.DISPLAY_ALERT]: DisplayAlertPayload;
|
|
5551
|
+
/** Demo end signal from game */
|
|
5552
|
+
[MessageEvents.DEMO_END]: DemoEndPayload;
|
|
5524
5553
|
/** Authentication state change notification */
|
|
5525
5554
|
[MessageEvents.AUTH_STATE_CHANGE]: AuthStateChangePayload;
|
|
5526
5555
|
/** OAuth callback data from popup/new-tab windows */
|
|
@@ -6097,6 +6126,20 @@ interface XpResponse {
|
|
|
6097
6126
|
*/
|
|
6098
6127
|
|
|
6099
6128
|
type TokenType = 'session' | 'apiKey' | 'gameJwt';
|
|
6129
|
+
/**
|
|
6130
|
+
* Runtime mode for a Playcademy game client.
|
|
6131
|
+
*
|
|
6132
|
+
* - `'platform'` — game is embedded in the platform (e.g. the cademy hub)
|
|
6133
|
+
* with a real authenticated user and full access to SDK namespaces.
|
|
6134
|
+
* - `'demo'` — game is embedded in the landing page demo shell with an
|
|
6135
|
+
* anonymous user; platform-only namespaces throw, and `client.demo.*`
|
|
6136
|
+
* is the supported surface for signaling demo lifecycle events and
|
|
6137
|
+
* reading/updating the anonymous profile.
|
|
6138
|
+
* - `'standalone'` — game is running outside any iframe (e.g. `bun run dev`
|
|
6139
|
+
* or direct-deploy preview) with a mock token and no real platform
|
|
6140
|
+
* context. API calls will not succeed; use this to branch UX locally.
|
|
6141
|
+
*/
|
|
6142
|
+
type PlaycademyMode = 'platform' | 'demo' | 'standalone';
|
|
6100
6143
|
interface ClientConfig {
|
|
6101
6144
|
baseUrl: string;
|
|
6102
6145
|
gameUrl?: string;
|
|
@@ -6107,6 +6150,7 @@ interface ClientConfig {
|
|
|
6107
6150
|
autoStartSession?: boolean;
|
|
6108
6151
|
onDisconnect?: DisconnectHandler;
|
|
6109
6152
|
enableConnectionMonitoring?: boolean;
|
|
6153
|
+
mode?: PlaycademyMode;
|
|
6110
6154
|
}
|
|
6111
6155
|
/**
|
|
6112
6156
|
* Handler called when connection state changes to offline or degraded.
|
|
@@ -6142,6 +6186,8 @@ interface InitPayload {
|
|
|
6142
6186
|
realtimeUrl?: string;
|
|
6143
6187
|
/** Timeback context (if user has a Timeback account) */
|
|
6144
6188
|
timeback?: TimebackInitContext;
|
|
6189
|
+
/** Runtime mode for the game client */
|
|
6190
|
+
mode?: PlaycademyMode;
|
|
6145
6191
|
}
|
|
6146
6192
|
/**
|
|
6147
6193
|
* Simplified user data passed to games via InitPayload
|
|
@@ -6170,6 +6216,7 @@ interface GameContextPayload {
|
|
|
6170
6216
|
realtimeUrl: string;
|
|
6171
6217
|
gameId: string;
|
|
6172
6218
|
forwardKeys?: string[];
|
|
6219
|
+
mode?: PlaycademyMode;
|
|
6173
6220
|
}
|
|
6174
6221
|
type EventListeners = {
|
|
6175
6222
|
[E in keyof ClientEvents]?: ((payload: ClientEvents[E]) => void)[];
|
|
@@ -6292,6 +6339,26 @@ interface ConnectionStatePayload {
|
|
|
6292
6339
|
state: 'online' | 'offline' | 'degraded';
|
|
6293
6340
|
reason: string;
|
|
6294
6341
|
}
|
|
6342
|
+
/**
|
|
6343
|
+
* Options for `client.demo.end(score, options?)`.
|
|
6344
|
+
*
|
|
6345
|
+
* All optional. The landing-page demo shell can render a meaningful CTA
|
|
6346
|
+
* from `score` alone, but `durationMs` enables a nicer summary and
|
|
6347
|
+
* `metadata` lets games pass any extra context they want to surface.
|
|
6348
|
+
*/
|
|
6349
|
+
interface DemoEndOptions {
|
|
6350
|
+
durationMs?: number;
|
|
6351
|
+
metadata?: Record<string, unknown>;
|
|
6352
|
+
}
|
|
6353
|
+
/**
|
|
6354
|
+
* Wire payload for the `PLAYCADEMY_DEMO_END` message.
|
|
6355
|
+
*
|
|
6356
|
+
* `score` is required — the demo shell always needs something to display
|
|
6357
|
+
* when the round ends. `durationMs` and `metadata` are optional.
|
|
6358
|
+
*/
|
|
6359
|
+
interface DemoEndPayload extends DemoEndOptions {
|
|
6360
|
+
score: number;
|
|
6361
|
+
}
|
|
6295
6362
|
|
|
6296
6363
|
/**
|
|
6297
6364
|
* SDK-specific API response types
|
|
@@ -7803,4 +7870,4 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
|
|
|
7803
7870
|
}
|
|
7804
7871
|
|
|
7805
7872
|
export { AchievementCompletionType, ApiError, ConnectionManager, ConnectionMonitor, MessageEvents, NotificationStatus, NotificationType, PlaycademyInternalClient as PlaycademyClient, PlaycademyError, PlaycademyInternalClient, extractApiErrorInfo, messaging };
|
|
7806
|
-
export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, ApiErrorCode, ApiErrorInfo, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionMonitorConfig, ConnectionState, ConnectionStatePayload, CourseXp, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, ErrorResponseBody, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameCustomHostname, GameInitUser, GameLeaderboardEntry, MapRow as GameMap, GamePlatform, GameRow as GameRecord, GameSessionRow as GameSession, GameTimebackIntegration, GameTokenResponse, GameType, GameUser, GetXpOptions, HostedGame, InitPayload, InsertCurrencyInput, InsertItemInput, InsertShopListingInput, InteractionType, InventoryItemRow as InventoryItem, InventoryItemWithItem, InventoryMutationResponse, ItemRow as Item, ItemType, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LevelConfigRow as LevelConfig, LevelProgressResponse, LevelUpCheckResult, LoginResponse, ManifestV1, MapData, MapElementRow as MapElement, MapElementMetadata, MapElementWithGame, MapObjectRow as MapObject, MapObjectWithItem, NotificationRow as Notification, NotificationStats, PlaceableItemMetadata, PlatformTimebackUser, PlatformTimebackUserContext, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacterRow as PlayerCharacter, PlayerCharacterAccessoryRow as PlayerCharacterAccessory, PlayerCurrency, PlayerInventoryItem, PlayerProfile, PlayerSessionPayload, PopulateStudentResponse, RealtimeTokenResponse, ScoreSubmission, ShopCurrency, ShopDisplayItem, ShopListingRow as ShopListing, ShopViewResponse, SpriteAnimationFrame, SpriteConfigWithDimensions, SpriteTemplateRow as SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TimebackEnrollment, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TimebackUserXp, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, UpdateCharacterData, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput, UpsertGameMetadataInput, UserRow as User, UserEnrollment, UserInfo, UserLevelRow as UserLevel, UserLevelWithConfig, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData, XPAddResult, XpHistoryResponse, XpResponse, XpSummaryResponse };
|
|
7873
|
+
export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, ApiErrorCode, ApiErrorInfo, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionMonitorConfig, ConnectionState, ConnectionStatePayload, CourseXp, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DemoEndOptions, DemoEndPayload, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, ErrorResponseBody, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameCustomHostname, GameInitUser, GameLeaderboardEntry, MapRow as GameMap, GamePlatform, GameRow as GameRecord, GameSessionRow as GameSession, GameTimebackIntegration, GameTokenResponse, GameType, GameUser, GetXpOptions, HostedGame, InitPayload, InsertCurrencyInput, InsertItemInput, InsertShopListingInput, InteractionType, InventoryItemRow as InventoryItem, InventoryItemWithItem, InventoryMutationResponse, ItemRow as Item, ItemType, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LevelConfigRow as LevelConfig, LevelProgressResponse, LevelUpCheckResult, LoginResponse, ManifestV1, MapData, MapElementRow as MapElement, MapElementMetadata, MapElementWithGame, MapObjectRow as MapObject, MapObjectWithItem, NotificationRow as Notification, NotificationStats, PlaceableItemMetadata, PlatformTimebackUser, PlatformTimebackUserContext, PlaycademyMode, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacterRow as PlayerCharacter, PlayerCharacterAccessoryRow as PlayerCharacterAccessory, PlayerCurrency, PlayerInventoryItem, PlayerProfile, PlayerSessionPayload, PopulateStudentResponse, RealtimeTokenResponse, ScoreSubmission, ShopCurrency, ShopDisplayItem, ShopListingRow as ShopListing, ShopViewResponse, SpriteAnimationFrame, SpriteConfigWithDimensions, SpriteTemplateRow as SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TimebackEnrollment, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TimebackUserXp, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, UpdateCharacterData, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput, UpsertGameMetadataInput, UserRow as User, UserEnrollment, UserInfo, UserLevelRow as UserLevel, UserLevelWithConfig, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData, XPAddResult, XpHistoryResponse, XpResponse, XpSummaryResponse };
|