@hyve-sdk/js 2.14.0-canary.0 → 2.14.0-canary.2
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.mts +31 -15
- package/dist/index.d.ts +31 -15
- package/dist/index.js +33 -18
- package/dist/index.mjs +33 -18
- package/dist/react.d.mts +6 -0
- package/dist/react.d.ts +6 -0
- package/dist/react.js +33 -18
- package/dist/react.mjs +33 -18
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -538,6 +538,12 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
538
538
|
* when omitted.
|
|
539
539
|
*/
|
|
540
540
|
partnerApiBaseUrl?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
543
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
544
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
545
|
+
*/
|
|
546
|
+
gameId?: string;
|
|
541
547
|
}
|
|
542
548
|
/**
|
|
543
549
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -950,8 +956,9 @@ declare class PlaygamaService {
|
|
|
950
956
|
/**
|
|
951
957
|
* CrazyGames SDK integration service
|
|
952
958
|
*
|
|
953
|
-
* Loads and initializes the CrazyGames SDK
|
|
954
|
-
* The SDK is loaded from CDN
|
|
959
|
+
* Loads and initializes the CrazyGames SDK v3 when running on the CrazyGames platform.
|
|
960
|
+
* The SDK is loaded from CDN, exposes a global `window.CrazyGames.SDK` object, and
|
|
961
|
+
* requires an explicit `await SDK.init()` before any module is usable.
|
|
955
962
|
*
|
|
956
963
|
* Detection: CrazyGames games run in an iframe on crazygames.com, so detection
|
|
957
964
|
* uses document.referrer and parent frame location checks.
|
|
@@ -991,23 +998,26 @@ interface CrazyGamesUserModule {
|
|
|
991
998
|
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
992
999
|
}
|
|
993
1000
|
/**
|
|
994
|
-
* CrazyGames key/value data store
|
|
995
|
-
*
|
|
996
|
-
* `await`
|
|
1001
|
+
* CrazyGames key/value data store (SDK v3). Methods are synchronous
|
|
1002
|
+
* (localStorage-like); the SDK debounces persistence by ~1s internally.
|
|
1003
|
+
* Wrappers still `await` the calls, which is harmless and future-proof.
|
|
997
1004
|
*/
|
|
998
1005
|
interface CrazyGamesDataModule {
|
|
999
|
-
getItem(key: string):
|
|
1000
|
-
setItem(key: string, value: string):
|
|
1001
|
-
removeItem(key: string):
|
|
1002
|
-
clear():
|
|
1003
|
-
getKeys?(): Promise<string[]> | string[];
|
|
1006
|
+
getItem(key: string): string | null;
|
|
1007
|
+
setItem(key: string, value: string): void;
|
|
1008
|
+
removeItem(key: string): void;
|
|
1009
|
+
clear(): void;
|
|
1004
1010
|
}
|
|
1005
1011
|
interface CrazyGamesSDK {
|
|
1012
|
+
/** v3 requires init() to be awaited before any module is used. */
|
|
1013
|
+
init(): Promise<void>;
|
|
1014
|
+
/** Resolved environment — a plain property in v3 (getEnvironment() was removed). */
|
|
1015
|
+
environment: CrazyGamesEnvironment;
|
|
1006
1016
|
ad: CrazyGamesAdModule;
|
|
1007
1017
|
game: CrazyGamesGameModule;
|
|
1008
1018
|
user: CrazyGamesUserModule;
|
|
1009
|
-
|
|
1010
|
-
|
|
1019
|
+
/** Absent unless the game submission has the "Progress Save" toggle enabled. */
|
|
1020
|
+
data?: CrazyGamesDataModule;
|
|
1011
1021
|
}
|
|
1012
1022
|
declare global {
|
|
1013
1023
|
interface Window {
|
|
@@ -1026,7 +1036,8 @@ declare class CrazyGamesService {
|
|
|
1026
1036
|
*/
|
|
1027
1037
|
static isCrazyGamesDomain(): boolean;
|
|
1028
1038
|
/**
|
|
1029
|
-
* Loads the CrazyGames SDK from CDN
|
|
1039
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1040
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1030
1041
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1031
1042
|
*/
|
|
1032
1043
|
initialize(): Promise<boolean>;
|
|
@@ -1087,8 +1098,13 @@ declare class CrazyGamesService {
|
|
|
1087
1098
|
/** Removes a previously registered auth listener. */
|
|
1088
1099
|
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1089
1100
|
/**
|
|
1090
|
-
*
|
|
1091
|
-
* is
|
|
1101
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1102
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1103
|
+
*/
|
|
1104
|
+
private getDataModule;
|
|
1105
|
+
/**
|
|
1106
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1107
|
+
* is absent.
|
|
1092
1108
|
*/
|
|
1093
1109
|
dataGetItem(key: string): Promise<string | null>;
|
|
1094
1110
|
/** Writes a value to the CrazyGames data store. */
|
package/dist/index.d.ts
CHANGED
|
@@ -538,6 +538,12 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
538
538
|
* when omitted.
|
|
539
539
|
*/
|
|
540
540
|
partnerApiBaseUrl?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
543
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
544
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
545
|
+
*/
|
|
546
|
+
gameId?: string;
|
|
541
547
|
}
|
|
542
548
|
/**
|
|
543
549
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -950,8 +956,9 @@ declare class PlaygamaService {
|
|
|
950
956
|
/**
|
|
951
957
|
* CrazyGames SDK integration service
|
|
952
958
|
*
|
|
953
|
-
* Loads and initializes the CrazyGames SDK
|
|
954
|
-
* The SDK is loaded from CDN
|
|
959
|
+
* Loads and initializes the CrazyGames SDK v3 when running on the CrazyGames platform.
|
|
960
|
+
* The SDK is loaded from CDN, exposes a global `window.CrazyGames.SDK` object, and
|
|
961
|
+
* requires an explicit `await SDK.init()` before any module is usable.
|
|
955
962
|
*
|
|
956
963
|
* Detection: CrazyGames games run in an iframe on crazygames.com, so detection
|
|
957
964
|
* uses document.referrer and parent frame location checks.
|
|
@@ -991,23 +998,26 @@ interface CrazyGamesUserModule {
|
|
|
991
998
|
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
992
999
|
}
|
|
993
1000
|
/**
|
|
994
|
-
* CrazyGames key/value data store
|
|
995
|
-
*
|
|
996
|
-
* `await`
|
|
1001
|
+
* CrazyGames key/value data store (SDK v3). Methods are synchronous
|
|
1002
|
+
* (localStorage-like); the SDK debounces persistence by ~1s internally.
|
|
1003
|
+
* Wrappers still `await` the calls, which is harmless and future-proof.
|
|
997
1004
|
*/
|
|
998
1005
|
interface CrazyGamesDataModule {
|
|
999
|
-
getItem(key: string):
|
|
1000
|
-
setItem(key: string, value: string):
|
|
1001
|
-
removeItem(key: string):
|
|
1002
|
-
clear():
|
|
1003
|
-
getKeys?(): Promise<string[]> | string[];
|
|
1006
|
+
getItem(key: string): string | null;
|
|
1007
|
+
setItem(key: string, value: string): void;
|
|
1008
|
+
removeItem(key: string): void;
|
|
1009
|
+
clear(): void;
|
|
1004
1010
|
}
|
|
1005
1011
|
interface CrazyGamesSDK {
|
|
1012
|
+
/** v3 requires init() to be awaited before any module is used. */
|
|
1013
|
+
init(): Promise<void>;
|
|
1014
|
+
/** Resolved environment — a plain property in v3 (getEnvironment() was removed). */
|
|
1015
|
+
environment: CrazyGamesEnvironment;
|
|
1006
1016
|
ad: CrazyGamesAdModule;
|
|
1007
1017
|
game: CrazyGamesGameModule;
|
|
1008
1018
|
user: CrazyGamesUserModule;
|
|
1009
|
-
|
|
1010
|
-
|
|
1019
|
+
/** Absent unless the game submission has the "Progress Save" toggle enabled. */
|
|
1020
|
+
data?: CrazyGamesDataModule;
|
|
1011
1021
|
}
|
|
1012
1022
|
declare global {
|
|
1013
1023
|
interface Window {
|
|
@@ -1026,7 +1036,8 @@ declare class CrazyGamesService {
|
|
|
1026
1036
|
*/
|
|
1027
1037
|
static isCrazyGamesDomain(): boolean;
|
|
1028
1038
|
/**
|
|
1029
|
-
* Loads the CrazyGames SDK from CDN
|
|
1039
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1040
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1030
1041
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1031
1042
|
*/
|
|
1032
1043
|
initialize(): Promise<boolean>;
|
|
@@ -1087,8 +1098,13 @@ declare class CrazyGamesService {
|
|
|
1087
1098
|
/** Removes a previously registered auth listener. */
|
|
1088
1099
|
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1089
1100
|
/**
|
|
1090
|
-
*
|
|
1091
|
-
* is
|
|
1101
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1102
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1103
|
+
*/
|
|
1104
|
+
private getDataModule;
|
|
1105
|
+
/**
|
|
1106
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1107
|
+
* is absent.
|
|
1092
1108
|
*/
|
|
1093
1109
|
dataGetItem(key: string): Promise<string | null>;
|
|
1094
1110
|
/** Writes a value to the CrazyGames data store. */
|
package/dist/index.js
CHANGED
|
@@ -1239,7 +1239,7 @@ var PlaygamaService = class {
|
|
|
1239
1239
|
};
|
|
1240
1240
|
|
|
1241
1241
|
// src/services/crazygames.ts
|
|
1242
|
-
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-
|
|
1242
|
+
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-v3.js";
|
|
1243
1243
|
var CrazyGamesService = class {
|
|
1244
1244
|
initialized = false;
|
|
1245
1245
|
environment = null;
|
|
@@ -1267,7 +1267,8 @@ var CrazyGamesService = class {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
1269
|
/**
|
|
1270
|
-
* Loads the CrazyGames SDK from CDN
|
|
1270
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1271
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1271
1272
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1272
1273
|
*/
|
|
1273
1274
|
async initialize() {
|
|
@@ -1279,13 +1280,19 @@ var CrazyGamesService = class {
|
|
|
1279
1280
|
logger.warn("[CrazyGamesService] SDK not found after script load");
|
|
1280
1281
|
return false;
|
|
1281
1282
|
}
|
|
1282
|
-
|
|
1283
|
+
await sdk.init();
|
|
1284
|
+
const env = sdk.environment;
|
|
1283
1285
|
if (env !== "crazygames" && env !== "local") {
|
|
1284
1286
|
logger.warn("[CrazyGamesService] Unexpected environment:", env);
|
|
1285
1287
|
return false;
|
|
1286
1288
|
}
|
|
1287
1289
|
this.environment = env;
|
|
1288
1290
|
this.initialized = true;
|
|
1291
|
+
if (!sdk.data) {
|
|
1292
|
+
logger.warn(
|
|
1293
|
+
'[CrazyGamesService] data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings to use persistent storage'
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1289
1296
|
return true;
|
|
1290
1297
|
} catch (error) {
|
|
1291
1298
|
logger.warn("[CrazyGamesService] Failed to initialize:", error);
|
|
@@ -1452,30 +1459,36 @@ var CrazyGamesService = class {
|
|
|
1452
1459
|
}
|
|
1453
1460
|
}
|
|
1454
1461
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
* is
|
|
1462
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1463
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1457
1464
|
*/
|
|
1458
|
-
|
|
1465
|
+
getDataModule() {
|
|
1459
1466
|
const sdk = window.CrazyGames?.SDK;
|
|
1460
|
-
if (!this.initialized || !sdk)
|
|
1461
|
-
|
|
1467
|
+
if (!this.initialized || !sdk) {
|
|
1468
|
+
throw new Error("CrazyGames SDK not initialized");
|
|
1469
|
+
}
|
|
1470
|
+
if (!sdk.data) {
|
|
1471
|
+
throw new Error(
|
|
1472
|
+
'CrazyGames data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings'
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
return sdk.data;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1479
|
+
* is absent.
|
|
1480
|
+
*/
|
|
1481
|
+
async dataGetItem(key) {
|
|
1482
|
+
const value = await this.getDataModule().getItem(key);
|
|
1462
1483
|
return value ?? null;
|
|
1463
1484
|
}
|
|
1464
1485
|
/** Writes a value to the CrazyGames data store. */
|
|
1465
1486
|
async dataSetItem(key, value) {
|
|
1466
|
-
|
|
1467
|
-
if (!this.initialized || !sdk) {
|
|
1468
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1469
|
-
}
|
|
1470
|
-
await sdk.data.setItem(key, value);
|
|
1487
|
+
await this.getDataModule().setItem(key, value);
|
|
1471
1488
|
}
|
|
1472
1489
|
/** Removes a value from the CrazyGames data store. */
|
|
1473
1490
|
async dataRemoveItem(key) {
|
|
1474
|
-
|
|
1475
|
-
if (!this.initialized || !sdk) {
|
|
1476
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1477
|
-
}
|
|
1478
|
-
await sdk.data.removeItem(key);
|
|
1491
|
+
await this.getDataModule().removeItem(key);
|
|
1479
1492
|
}
|
|
1480
1493
|
loadScript() {
|
|
1481
1494
|
return new Promise((resolve, reject) => {
|
|
@@ -2380,6 +2393,7 @@ var HyveClient = class {
|
|
|
2380
2393
|
}
|
|
2381
2394
|
this.partnerApiKey = config?.partnerApiKey ?? null;
|
|
2382
2395
|
this.partnerApiBaseUrl = config?.partnerApiBaseUrl ?? null;
|
|
2396
|
+
this.gameId = config?.gameId ?? null;
|
|
2383
2397
|
if (typeof window !== "undefined" && CrazyGamesService.isCrazyGamesDomain()) {
|
|
2384
2398
|
this.crazyGamesService = new CrazyGamesService();
|
|
2385
2399
|
this.crazyGamesStorageAdapter = new CrazyGamesStorageAdapter(this.crazyGamesService);
|
|
@@ -2424,6 +2438,7 @@ var HyveClient = class {
|
|
|
2424
2438
|
!!config?.billing && Object.keys(config.billing).length > 0
|
|
2425
2439
|
);
|
|
2426
2440
|
logger.info("Storage mode:", this.storageMode);
|
|
2441
|
+
logger.info("Game ID:", this.gameId ?? "not set");
|
|
2427
2442
|
logger.info("Authenticated:", this.jwtToken !== null);
|
|
2428
2443
|
logger.debug("Config:", {
|
|
2429
2444
|
isDev: this.telemetryConfig.isDev,
|
package/dist/index.mjs
CHANGED
|
@@ -1198,7 +1198,7 @@ var PlaygamaService = class {
|
|
|
1198
1198
|
};
|
|
1199
1199
|
|
|
1200
1200
|
// src/services/crazygames.ts
|
|
1201
|
-
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-
|
|
1201
|
+
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-v3.js";
|
|
1202
1202
|
var CrazyGamesService = class {
|
|
1203
1203
|
initialized = false;
|
|
1204
1204
|
environment = null;
|
|
@@ -1226,7 +1226,8 @@ var CrazyGamesService = class {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
}
|
|
1228
1228
|
/**
|
|
1229
|
-
* Loads the CrazyGames SDK from CDN
|
|
1229
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1230
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1230
1231
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1231
1232
|
*/
|
|
1232
1233
|
async initialize() {
|
|
@@ -1238,13 +1239,19 @@ var CrazyGamesService = class {
|
|
|
1238
1239
|
logger.warn("[CrazyGamesService] SDK not found after script load");
|
|
1239
1240
|
return false;
|
|
1240
1241
|
}
|
|
1241
|
-
|
|
1242
|
+
await sdk.init();
|
|
1243
|
+
const env = sdk.environment;
|
|
1242
1244
|
if (env !== "crazygames" && env !== "local") {
|
|
1243
1245
|
logger.warn("[CrazyGamesService] Unexpected environment:", env);
|
|
1244
1246
|
return false;
|
|
1245
1247
|
}
|
|
1246
1248
|
this.environment = env;
|
|
1247
1249
|
this.initialized = true;
|
|
1250
|
+
if (!sdk.data) {
|
|
1251
|
+
logger.warn(
|
|
1252
|
+
'[CrazyGamesService] data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings to use persistent storage'
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1248
1255
|
return true;
|
|
1249
1256
|
} catch (error) {
|
|
1250
1257
|
logger.warn("[CrazyGamesService] Failed to initialize:", error);
|
|
@@ -1411,30 +1418,36 @@ var CrazyGamesService = class {
|
|
|
1411
1418
|
}
|
|
1412
1419
|
}
|
|
1413
1420
|
/**
|
|
1414
|
-
*
|
|
1415
|
-
* is
|
|
1421
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1422
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1416
1423
|
*/
|
|
1417
|
-
|
|
1424
|
+
getDataModule() {
|
|
1418
1425
|
const sdk = window.CrazyGames?.SDK;
|
|
1419
|
-
if (!this.initialized || !sdk)
|
|
1420
|
-
|
|
1426
|
+
if (!this.initialized || !sdk) {
|
|
1427
|
+
throw new Error("CrazyGames SDK not initialized");
|
|
1428
|
+
}
|
|
1429
|
+
if (!sdk.data) {
|
|
1430
|
+
throw new Error(
|
|
1431
|
+
'CrazyGames data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings'
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1434
|
+
return sdk.data;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1438
|
+
* is absent.
|
|
1439
|
+
*/
|
|
1440
|
+
async dataGetItem(key) {
|
|
1441
|
+
const value = await this.getDataModule().getItem(key);
|
|
1421
1442
|
return value ?? null;
|
|
1422
1443
|
}
|
|
1423
1444
|
/** Writes a value to the CrazyGames data store. */
|
|
1424
1445
|
async dataSetItem(key, value) {
|
|
1425
|
-
|
|
1426
|
-
if (!this.initialized || !sdk) {
|
|
1427
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1428
|
-
}
|
|
1429
|
-
await sdk.data.setItem(key, value);
|
|
1446
|
+
await this.getDataModule().setItem(key, value);
|
|
1430
1447
|
}
|
|
1431
1448
|
/** Removes a value from the CrazyGames data store. */
|
|
1432
1449
|
async dataRemoveItem(key) {
|
|
1433
|
-
|
|
1434
|
-
if (!this.initialized || !sdk) {
|
|
1435
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1436
|
-
}
|
|
1437
|
-
await sdk.data.removeItem(key);
|
|
1450
|
+
await this.getDataModule().removeItem(key);
|
|
1438
1451
|
}
|
|
1439
1452
|
loadScript() {
|
|
1440
1453
|
return new Promise((resolve, reject) => {
|
|
@@ -2339,6 +2352,7 @@ var HyveClient = class {
|
|
|
2339
2352
|
}
|
|
2340
2353
|
this.partnerApiKey = config?.partnerApiKey ?? null;
|
|
2341
2354
|
this.partnerApiBaseUrl = config?.partnerApiBaseUrl ?? null;
|
|
2355
|
+
this.gameId = config?.gameId ?? null;
|
|
2342
2356
|
if (typeof window !== "undefined" && CrazyGamesService.isCrazyGamesDomain()) {
|
|
2343
2357
|
this.crazyGamesService = new CrazyGamesService();
|
|
2344
2358
|
this.crazyGamesStorageAdapter = new CrazyGamesStorageAdapter(this.crazyGamesService);
|
|
@@ -2383,6 +2397,7 @@ var HyveClient = class {
|
|
|
2383
2397
|
!!config?.billing && Object.keys(config.billing).length > 0
|
|
2384
2398
|
);
|
|
2385
2399
|
logger.info("Storage mode:", this.storageMode);
|
|
2400
|
+
logger.info("Game ID:", this.gameId ?? "not set");
|
|
2386
2401
|
logger.info("Authenticated:", this.jwtToken !== null);
|
|
2387
2402
|
logger.debug("Config:", {
|
|
2388
2403
|
isDev: this.telemetryConfig.isDev,
|
package/dist/react.d.mts
CHANGED
|
@@ -269,6 +269,12 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
269
269
|
* when omitted.
|
|
270
270
|
*/
|
|
271
271
|
partnerApiBaseUrl?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
274
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
275
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
276
|
+
*/
|
|
277
|
+
gameId?: string;
|
|
272
278
|
}
|
|
273
279
|
/**
|
|
274
280
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
package/dist/react.d.ts
CHANGED
|
@@ -269,6 +269,12 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
269
269
|
* when omitted.
|
|
270
270
|
*/
|
|
271
271
|
partnerApiBaseUrl?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
274
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
275
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
276
|
+
*/
|
|
277
|
+
gameId?: string;
|
|
272
278
|
}
|
|
273
279
|
/**
|
|
274
280
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
package/dist/react.js
CHANGED
|
@@ -1196,7 +1196,7 @@ var PlaygamaService = class {
|
|
|
1196
1196
|
};
|
|
1197
1197
|
|
|
1198
1198
|
// src/services/crazygames.ts
|
|
1199
|
-
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-
|
|
1199
|
+
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-v3.js";
|
|
1200
1200
|
var CrazyGamesService = class {
|
|
1201
1201
|
initialized = false;
|
|
1202
1202
|
environment = null;
|
|
@@ -1224,7 +1224,8 @@ var CrazyGamesService = class {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
}
|
|
1226
1226
|
/**
|
|
1227
|
-
* Loads the CrazyGames SDK from CDN
|
|
1227
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1228
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1228
1229
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1229
1230
|
*/
|
|
1230
1231
|
async initialize() {
|
|
@@ -1236,13 +1237,19 @@ var CrazyGamesService = class {
|
|
|
1236
1237
|
logger.warn("[CrazyGamesService] SDK not found after script load");
|
|
1237
1238
|
return false;
|
|
1238
1239
|
}
|
|
1239
|
-
|
|
1240
|
+
await sdk.init();
|
|
1241
|
+
const env = sdk.environment;
|
|
1240
1242
|
if (env !== "crazygames" && env !== "local") {
|
|
1241
1243
|
logger.warn("[CrazyGamesService] Unexpected environment:", env);
|
|
1242
1244
|
return false;
|
|
1243
1245
|
}
|
|
1244
1246
|
this.environment = env;
|
|
1245
1247
|
this.initialized = true;
|
|
1248
|
+
if (!sdk.data) {
|
|
1249
|
+
logger.warn(
|
|
1250
|
+
'[CrazyGamesService] data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings to use persistent storage'
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1246
1253
|
return true;
|
|
1247
1254
|
} catch (error) {
|
|
1248
1255
|
logger.warn("[CrazyGamesService] Failed to initialize:", error);
|
|
@@ -1409,30 +1416,36 @@ var CrazyGamesService = class {
|
|
|
1409
1416
|
}
|
|
1410
1417
|
}
|
|
1411
1418
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
* is
|
|
1419
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1420
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1414
1421
|
*/
|
|
1415
|
-
|
|
1422
|
+
getDataModule() {
|
|
1416
1423
|
const sdk = window.CrazyGames?.SDK;
|
|
1417
|
-
if (!this.initialized || !sdk)
|
|
1418
|
-
|
|
1424
|
+
if (!this.initialized || !sdk) {
|
|
1425
|
+
throw new Error("CrazyGames SDK not initialized");
|
|
1426
|
+
}
|
|
1427
|
+
if (!sdk.data) {
|
|
1428
|
+
throw new Error(
|
|
1429
|
+
'CrazyGames data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings'
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1432
|
+
return sdk.data;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1436
|
+
* is absent.
|
|
1437
|
+
*/
|
|
1438
|
+
async dataGetItem(key) {
|
|
1439
|
+
const value = await this.getDataModule().getItem(key);
|
|
1419
1440
|
return value ?? null;
|
|
1420
1441
|
}
|
|
1421
1442
|
/** Writes a value to the CrazyGames data store. */
|
|
1422
1443
|
async dataSetItem(key, value) {
|
|
1423
|
-
|
|
1424
|
-
if (!this.initialized || !sdk) {
|
|
1425
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1426
|
-
}
|
|
1427
|
-
await sdk.data.setItem(key, value);
|
|
1444
|
+
await this.getDataModule().setItem(key, value);
|
|
1428
1445
|
}
|
|
1429
1446
|
/** Removes a value from the CrazyGames data store. */
|
|
1430
1447
|
async dataRemoveItem(key) {
|
|
1431
|
-
|
|
1432
|
-
if (!this.initialized || !sdk) {
|
|
1433
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1434
|
-
}
|
|
1435
|
-
await sdk.data.removeItem(key);
|
|
1448
|
+
await this.getDataModule().removeItem(key);
|
|
1436
1449
|
}
|
|
1437
1450
|
loadScript() {
|
|
1438
1451
|
return new Promise((resolve, reject) => {
|
|
@@ -2331,6 +2344,7 @@ var HyveClient = class {
|
|
|
2331
2344
|
}
|
|
2332
2345
|
this.partnerApiKey = config?.partnerApiKey ?? null;
|
|
2333
2346
|
this.partnerApiBaseUrl = config?.partnerApiBaseUrl ?? null;
|
|
2347
|
+
this.gameId = config?.gameId ?? null;
|
|
2334
2348
|
if (typeof window !== "undefined" && CrazyGamesService.isCrazyGamesDomain()) {
|
|
2335
2349
|
this.crazyGamesService = new CrazyGamesService();
|
|
2336
2350
|
this.crazyGamesStorageAdapter = new CrazyGamesStorageAdapter(this.crazyGamesService);
|
|
@@ -2375,6 +2389,7 @@ var HyveClient = class {
|
|
|
2375
2389
|
!!config?.billing && Object.keys(config.billing).length > 0
|
|
2376
2390
|
);
|
|
2377
2391
|
logger.info("Storage mode:", this.storageMode);
|
|
2392
|
+
logger.info("Game ID:", this.gameId ?? "not set");
|
|
2378
2393
|
logger.info("Authenticated:", this.jwtToken !== null);
|
|
2379
2394
|
logger.debug("Config:", {
|
|
2380
2395
|
isDev: this.telemetryConfig.isDev,
|
package/dist/react.mjs
CHANGED
|
@@ -1174,7 +1174,7 @@ var PlaygamaService = class {
|
|
|
1174
1174
|
};
|
|
1175
1175
|
|
|
1176
1176
|
// src/services/crazygames.ts
|
|
1177
|
-
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-
|
|
1177
|
+
var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-v3.js";
|
|
1178
1178
|
var CrazyGamesService = class {
|
|
1179
1179
|
initialized = false;
|
|
1180
1180
|
environment = null;
|
|
@@ -1202,7 +1202,8 @@ var CrazyGamesService = class {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
1204
|
/**
|
|
1205
|
-
* Loads the CrazyGames SDK from CDN
|
|
1205
|
+
* Loads the CrazyGames SDK v3 from CDN, runs the mandatory `SDK.init()`, and
|
|
1206
|
+
* confirms the environment is 'crazygames' (or 'local' for dev).
|
|
1206
1207
|
* Safe to call multiple times — resolves immediately if already initialized.
|
|
1207
1208
|
*/
|
|
1208
1209
|
async initialize() {
|
|
@@ -1214,13 +1215,19 @@ var CrazyGamesService = class {
|
|
|
1214
1215
|
logger.warn("[CrazyGamesService] SDK not found after script load");
|
|
1215
1216
|
return false;
|
|
1216
1217
|
}
|
|
1217
|
-
|
|
1218
|
+
await sdk.init();
|
|
1219
|
+
const env = sdk.environment;
|
|
1218
1220
|
if (env !== "crazygames" && env !== "local") {
|
|
1219
1221
|
logger.warn("[CrazyGamesService] Unexpected environment:", env);
|
|
1220
1222
|
return false;
|
|
1221
1223
|
}
|
|
1222
1224
|
this.environment = env;
|
|
1223
1225
|
this.initialized = true;
|
|
1226
|
+
if (!sdk.data) {
|
|
1227
|
+
logger.warn(
|
|
1228
|
+
'[CrazyGamesService] data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings to use persistent storage'
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1224
1231
|
return true;
|
|
1225
1232
|
} catch (error) {
|
|
1226
1233
|
logger.warn("[CrazyGamesService] Failed to initialize:", error);
|
|
@@ -1387,30 +1394,36 @@ var CrazyGamesService = class {
|
|
|
1387
1394
|
}
|
|
1388
1395
|
}
|
|
1389
1396
|
/**
|
|
1390
|
-
*
|
|
1391
|
-
* is
|
|
1397
|
+
* Returns the SDK v3 data module, throwing an actionable error when the SDK
|
|
1398
|
+
* is not initialized or the module is disabled for this game submission.
|
|
1392
1399
|
*/
|
|
1393
|
-
|
|
1400
|
+
getDataModule() {
|
|
1394
1401
|
const sdk = window.CrazyGames?.SDK;
|
|
1395
|
-
if (!this.initialized || !sdk)
|
|
1396
|
-
|
|
1402
|
+
if (!this.initialized || !sdk) {
|
|
1403
|
+
throw new Error("CrazyGames SDK not initialized");
|
|
1404
|
+
}
|
|
1405
|
+
if (!sdk.data) {
|
|
1406
|
+
throw new Error(
|
|
1407
|
+
'CrazyGames data module unavailable \u2014 enable the "Progress Save" toggle in the CrazyGames game submission settings'
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1410
|
+
return sdk.data;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Reads a value from the CrazyGames data store. Returns null when the key
|
|
1414
|
+
* is absent.
|
|
1415
|
+
*/
|
|
1416
|
+
async dataGetItem(key) {
|
|
1417
|
+
const value = await this.getDataModule().getItem(key);
|
|
1397
1418
|
return value ?? null;
|
|
1398
1419
|
}
|
|
1399
1420
|
/** Writes a value to the CrazyGames data store. */
|
|
1400
1421
|
async dataSetItem(key, value) {
|
|
1401
|
-
|
|
1402
|
-
if (!this.initialized || !sdk) {
|
|
1403
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1404
|
-
}
|
|
1405
|
-
await sdk.data.setItem(key, value);
|
|
1422
|
+
await this.getDataModule().setItem(key, value);
|
|
1406
1423
|
}
|
|
1407
1424
|
/** Removes a value from the CrazyGames data store. */
|
|
1408
1425
|
async dataRemoveItem(key) {
|
|
1409
|
-
|
|
1410
|
-
if (!this.initialized || !sdk) {
|
|
1411
|
-
throw new Error("CrazyGames SDK not initialized");
|
|
1412
|
-
}
|
|
1413
|
-
await sdk.data.removeItem(key);
|
|
1426
|
+
await this.getDataModule().removeItem(key);
|
|
1414
1427
|
}
|
|
1415
1428
|
loadScript() {
|
|
1416
1429
|
return new Promise((resolve, reject) => {
|
|
@@ -2309,6 +2322,7 @@ var HyveClient = class {
|
|
|
2309
2322
|
}
|
|
2310
2323
|
this.partnerApiKey = config?.partnerApiKey ?? null;
|
|
2311
2324
|
this.partnerApiBaseUrl = config?.partnerApiBaseUrl ?? null;
|
|
2325
|
+
this.gameId = config?.gameId ?? null;
|
|
2312
2326
|
if (typeof window !== "undefined" && CrazyGamesService.isCrazyGamesDomain()) {
|
|
2313
2327
|
this.crazyGamesService = new CrazyGamesService();
|
|
2314
2328
|
this.crazyGamesStorageAdapter = new CrazyGamesStorageAdapter(this.crazyGamesService);
|
|
@@ -2353,6 +2367,7 @@ var HyveClient = class {
|
|
|
2353
2367
|
!!config?.billing && Object.keys(config.billing).length > 0
|
|
2354
2368
|
);
|
|
2355
2369
|
logger.info("Storage mode:", this.storageMode);
|
|
2370
|
+
logger.info("Game ID:", this.gameId ?? "not set");
|
|
2356
2371
|
logger.info("Authenticated:", this.jwtToken !== null);
|
|
2357
2372
|
logger.debug("Config:", {
|
|
2358
2373
|
isDev: this.telemetryConfig.isDev,
|