@hyve-sdk/js 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -443,6 +443,7 @@ declare class HyveClient {
443
443
  private jwtToken;
444
444
  private gameId;
445
445
  private adsService;
446
+ private playgamaService;
446
447
  private billingService;
447
448
  private billingConfig;
448
449
  private billingCallbacks;
@@ -674,6 +675,54 @@ declare class HyveClient {
674
675
  onBillingLog(callback: (level: "info" | "warn" | "error", message: string, data?: any) => void): void;
675
676
  }
676
677
 
678
+ /**
679
+ * Playgama Bridge integration service
680
+ *
681
+ * Loads and initializes the Playgama Bridge SDK when running on a Playgama domain.
682
+ * The bridge SDK is loaded from CDN and exposes a global `window.bridge` object.
683
+ *
684
+ * Detection: Playgama games receive a `platform_id=playgama` URL parameter when
685
+ * embedded on the platform.
686
+ *
687
+ * @packageDocumentation
688
+ */
689
+
690
+ interface PlaygamaBridgeAdvertisement {
691
+ interstitialState: string;
692
+ rewardedState: string;
693
+ showInterstitial(placement?: string): void;
694
+ showRewarded(placement?: string): void;
695
+ on(event: string, callback: (state: string) => void): void;
696
+ off(event: string, callback: (state: string) => void): void;
697
+ }
698
+ interface PlaygamaBridge {
699
+ initialize(): Promise<void>;
700
+ advertisement: PlaygamaBridgeAdvertisement;
701
+ }
702
+ declare global {
703
+ interface Window {
704
+ bridge?: PlaygamaBridge;
705
+ }
706
+ }
707
+ declare class PlaygamaService {
708
+ private initialized;
709
+ /**
710
+ * Detects if the game is running on the Playgama platform.
711
+ * Playgama injects a `platform_id=playgama` URL parameter into the game URL.
712
+ * Falls back to checking document.referrer for playgama.com.
713
+ */
714
+ static isPlaygamaDomain(): boolean;
715
+ /**
716
+ * Loads the Playgama Bridge script from CDN and initializes it.
717
+ * Safe to call multiple times - resolves immediately if already initialized.
718
+ */
719
+ initialize(): Promise<boolean>;
720
+ isInitialized(): boolean;
721
+ showInterstitial(): Promise<AdResult>;
722
+ showRewarded(): Promise<AdResult>;
723
+ private loadScript;
724
+ }
725
+
677
726
  /**
678
727
  * Storage adapter interface - supports cloud and local implementations
679
728
  */
@@ -988,4 +1037,4 @@ declare class NativeBridge {
988
1037
  */
989
1038
  declare function generateUUID(): string;
990
1039
 
991
- export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
1040
+ export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
package/dist/index.d.ts CHANGED
@@ -443,6 +443,7 @@ declare class HyveClient {
443
443
  private jwtToken;
444
444
  private gameId;
445
445
  private adsService;
446
+ private playgamaService;
446
447
  private billingService;
447
448
  private billingConfig;
448
449
  private billingCallbacks;
@@ -674,6 +675,54 @@ declare class HyveClient {
674
675
  onBillingLog(callback: (level: "info" | "warn" | "error", message: string, data?: any) => void): void;
675
676
  }
676
677
 
678
+ /**
679
+ * Playgama Bridge integration service
680
+ *
681
+ * Loads and initializes the Playgama Bridge SDK when running on a Playgama domain.
682
+ * The bridge SDK is loaded from CDN and exposes a global `window.bridge` object.
683
+ *
684
+ * Detection: Playgama games receive a `platform_id=playgama` URL parameter when
685
+ * embedded on the platform.
686
+ *
687
+ * @packageDocumentation
688
+ */
689
+
690
+ interface PlaygamaBridgeAdvertisement {
691
+ interstitialState: string;
692
+ rewardedState: string;
693
+ showInterstitial(placement?: string): void;
694
+ showRewarded(placement?: string): void;
695
+ on(event: string, callback: (state: string) => void): void;
696
+ off(event: string, callback: (state: string) => void): void;
697
+ }
698
+ interface PlaygamaBridge {
699
+ initialize(): Promise<void>;
700
+ advertisement: PlaygamaBridgeAdvertisement;
701
+ }
702
+ declare global {
703
+ interface Window {
704
+ bridge?: PlaygamaBridge;
705
+ }
706
+ }
707
+ declare class PlaygamaService {
708
+ private initialized;
709
+ /**
710
+ * Detects if the game is running on the Playgama platform.
711
+ * Playgama injects a `platform_id=playgama` URL parameter into the game URL.
712
+ * Falls back to checking document.referrer for playgama.com.
713
+ */
714
+ static isPlaygamaDomain(): boolean;
715
+ /**
716
+ * Loads the Playgama Bridge script from CDN and initializes it.
717
+ * Safe to call multiple times - resolves immediately if already initialized.
718
+ */
719
+ initialize(): Promise<boolean>;
720
+ isInitialized(): boolean;
721
+ showInterstitial(): Promise<AdResult>;
722
+ showRewarded(): Promise<AdResult>;
723
+ private loadScript;
724
+ }
725
+
677
726
  /**
678
727
  * Storage adapter interface - supports cloud and local implementations
679
728
  */
@@ -988,4 +1037,4 @@ declare class NativeBridge {
988
1037
  */
989
1038
  declare function generateUUID(): string;
990
1039
 
991
- export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
1040
+ export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  Logger: () => Logger,
30
30
  NativeBridge: () => NativeBridge,
31
31
  NativeMessageType: () => NativeMessageType,
32
+ PlaygamaService: () => PlaygamaService,
32
33
  generateUUID: () => generateUUID,
33
34
  handleVerifyMessage: () => handleVerifyMessage,
34
35
  isDomainAllowed: () => isDomainAllowed,
@@ -799,6 +800,133 @@ var AdsService = class {
799
800
  }
800
801
  };
801
802
 
803
+ // src/services/playgama.ts
804
+ var PLAYGAMA_BRIDGE_CDN = "https://bridge.playgama.com/v1/stable/playgama-bridge.js";
805
+ var PlaygamaService = class {
806
+ initialized = false;
807
+ /**
808
+ * Detects if the game is running on the Playgama platform.
809
+ * Playgama injects a `platform_id=playgama` URL parameter into the game URL.
810
+ * Falls back to checking document.referrer for playgama.com.
811
+ */
812
+ static isPlaygamaDomain() {
813
+ try {
814
+ const url = new URL(window.location.href);
815
+ if (url.searchParams.get("platform_id") === "playgama") {
816
+ return true;
817
+ }
818
+ if (document.referrer.includes("playgama.com")) {
819
+ return true;
820
+ }
821
+ if (window !== window.top) {
822
+ try {
823
+ if (window.parent.location.hostname.includes("playgama.com")) {
824
+ return true;
825
+ }
826
+ } catch {
827
+ }
828
+ }
829
+ return false;
830
+ } catch {
831
+ return false;
832
+ }
833
+ }
834
+ /**
835
+ * Loads the Playgama Bridge script from CDN and initializes it.
836
+ * Safe to call multiple times - resolves immediately if already initialized.
837
+ */
838
+ async initialize() {
839
+ if (this.initialized) return true;
840
+ try {
841
+ await this.loadScript();
842
+ await window.bridge.initialize();
843
+ this.initialized = true;
844
+ return true;
845
+ } catch (error) {
846
+ console.warn("[PlaygamaService] Failed to initialize:", error);
847
+ return false;
848
+ }
849
+ }
850
+ isInitialized() {
851
+ return this.initialized;
852
+ }
853
+ async showInterstitial() {
854
+ const requestedAt = Date.now();
855
+ if (!this.initialized || !window.bridge) {
856
+ return {
857
+ success: false,
858
+ type: "interstitial",
859
+ error: new Error("Playgama not initialized"),
860
+ requestedAt,
861
+ completedAt: Date.now()
862
+ };
863
+ }
864
+ return new Promise((resolve) => {
865
+ const handler = (state) => {
866
+ if (state === "closed") {
867
+ window.bridge.advertisement.off("interstitial_state_changed", handler);
868
+ resolve({ success: true, type: "interstitial", requestedAt, completedAt: Date.now() });
869
+ } else if (state === "failed") {
870
+ window.bridge.advertisement.off("interstitial_state_changed", handler);
871
+ resolve({
872
+ success: false,
873
+ type: "interstitial",
874
+ error: new Error("Interstitial ad failed"),
875
+ requestedAt,
876
+ completedAt: Date.now()
877
+ });
878
+ }
879
+ };
880
+ window.bridge.advertisement.on("interstitial_state_changed", handler);
881
+ window.bridge.advertisement.showInterstitial();
882
+ });
883
+ }
884
+ async showRewarded() {
885
+ const requestedAt = Date.now();
886
+ if (!this.initialized || !window.bridge) {
887
+ return {
888
+ success: false,
889
+ type: "rewarded",
890
+ error: new Error("Playgama not initialized"),
891
+ requestedAt,
892
+ completedAt: Date.now()
893
+ };
894
+ }
895
+ return new Promise((resolve) => {
896
+ let rewarded = false;
897
+ const handler = (state) => {
898
+ if (state === "rewarded") {
899
+ rewarded = true;
900
+ } else if (state === "closed" || state === "failed") {
901
+ window.bridge.advertisement.off("rewarded_state_changed", handler);
902
+ resolve({
903
+ success: rewarded,
904
+ type: "rewarded",
905
+ error: !rewarded ? new Error("Rewarded ad not completed") : void 0,
906
+ requestedAt,
907
+ completedAt: Date.now()
908
+ });
909
+ }
910
+ };
911
+ window.bridge.advertisement.on("rewarded_state_changed", handler);
912
+ window.bridge.advertisement.showRewarded();
913
+ });
914
+ }
915
+ loadScript() {
916
+ return new Promise((resolve, reject) => {
917
+ if (window.bridge) {
918
+ resolve();
919
+ return;
920
+ }
921
+ const script = document.createElement("script");
922
+ script.src = PLAYGAMA_BRIDGE_CDN;
923
+ script.onload = () => resolve();
924
+ script.onerror = () => reject(new Error("Failed to load Playgama Bridge script"));
925
+ document.head.appendChild(script);
926
+ });
927
+ }
928
+ };
929
+
802
930
  // src/services/billing.ts
803
931
  var BillingPlatform = /* @__PURE__ */ ((BillingPlatform3) => {
804
932
  BillingPlatform3["WEB"] = "web";
@@ -1251,14 +1379,21 @@ var BillingService = class {
1251
1379
  throw new Error("Stripe not initialized");
1252
1380
  }
1253
1381
  try {
1382
+ if (this.checkoutElement) {
1383
+ this.log("info", "[BillingService] Unmounting existing checkout element");
1384
+ this.unmountCheckoutElement();
1385
+ await new Promise((resolve) => setTimeout(resolve, 100));
1386
+ }
1254
1387
  const container = document.getElementById(elementId);
1255
1388
  if (!container) {
1256
1389
  throw new Error(`Element with id "${elementId}" not found in the DOM`);
1257
1390
  }
1258
1391
  container.innerHTML = "";
1392
+ this.log("info", "[BillingService] Creating new checkout instance");
1259
1393
  this.checkoutElement = await this.stripe.initEmbeddedCheckout({
1260
1394
  clientSecret
1261
1395
  });
1396
+ this.log("info", "[BillingService] Mounting checkout element to DOM");
1262
1397
  this.checkoutElement.mount(`#${elementId}`);
1263
1398
  this.setupCheckoutEventListeners();
1264
1399
  } catch (error) {
@@ -1296,7 +1431,14 @@ var BillingService = class {
1296
1431
  */
1297
1432
  unmountCheckoutElement() {
1298
1433
  if (this.checkoutElement) {
1299
- this.checkoutElement.unmount();
1434
+ try {
1435
+ this.checkoutElement.unmount();
1436
+ if (typeof this.checkoutElement.destroy === "function") {
1437
+ this.checkoutElement.destroy();
1438
+ }
1439
+ } catch (error) {
1440
+ this.log("warn", "[BillingService] Error unmounting checkout element:", error?.message);
1441
+ }
1300
1442
  this.checkoutElement = null;
1301
1443
  }
1302
1444
  }
@@ -1496,6 +1638,7 @@ var HyveClient = class {
1496
1638
  jwtToken = null;
1497
1639
  gameId = null;
1498
1640
  adsService;
1641
+ playgamaService = null;
1499
1642
  billingService;
1500
1643
  billingConfig;
1501
1644
  // Store callbacks to preserve them when recreating BillingService
@@ -1523,6 +1666,12 @@ var HyveClient = class {
1523
1666
  if (config?.ads) {
1524
1667
  this.adsService.configure(config.ads);
1525
1668
  }
1669
+ if (typeof window !== "undefined" && PlaygamaService.isPlaygamaDomain()) {
1670
+ this.playgamaService = new PlaygamaService();
1671
+ this.playgamaService.initialize().then((success) => {
1672
+ logger.info("Playgama Bridge initialized:", success);
1673
+ });
1674
+ }
1526
1675
  this.billingConfig = config?.billing || {};
1527
1676
  this.billingService = new BillingService(this.billingConfig);
1528
1677
  this.storageMode = config?.storageMode || "cloud";
@@ -1542,6 +1691,7 @@ var HyveClient = class {
1542
1691
  );
1543
1692
  logger.info("API Base URL:", this.apiBaseUrl);
1544
1693
  logger.info("Ads enabled:", this.adsService.isEnabled());
1694
+ logger.info("Playgama platform:", this.playgamaService !== null);
1545
1695
  logger.info(
1546
1696
  "Billing configured:",
1547
1697
  Object.keys(this.billingConfig).length > 0
@@ -1971,6 +2121,10 @@ var HyveClient = class {
1971
2121
  * @returns Promise resolving to ad result
1972
2122
  */
1973
2123
  async showAd(type) {
2124
+ if (this.playgamaService?.isInitialized()) {
2125
+ if (type === "rewarded") return this.playgamaService.showRewarded();
2126
+ return this.playgamaService.showInterstitial();
2127
+ }
1974
2128
  return this.adsService.show(type);
1975
2129
  }
1976
2130
  /**
@@ -2100,6 +2254,7 @@ var HyveClient = class {
2100
2254
  Logger,
2101
2255
  NativeBridge,
2102
2256
  NativeMessageType,
2257
+ PlaygamaService,
2103
2258
  generateUUID,
2104
2259
  handleVerifyMessage,
2105
2260
  isDomainAllowed,
package/dist/index.mjs CHANGED
@@ -757,6 +757,133 @@ var AdsService = class {
757
757
  }
758
758
  };
759
759
 
760
+ // src/services/playgama.ts
761
+ var PLAYGAMA_BRIDGE_CDN = "https://bridge.playgama.com/v1/stable/playgama-bridge.js";
762
+ var PlaygamaService = class {
763
+ initialized = false;
764
+ /**
765
+ * Detects if the game is running on the Playgama platform.
766
+ * Playgama injects a `platform_id=playgama` URL parameter into the game URL.
767
+ * Falls back to checking document.referrer for playgama.com.
768
+ */
769
+ static isPlaygamaDomain() {
770
+ try {
771
+ const url = new URL(window.location.href);
772
+ if (url.searchParams.get("platform_id") === "playgama") {
773
+ return true;
774
+ }
775
+ if (document.referrer.includes("playgama.com")) {
776
+ return true;
777
+ }
778
+ if (window !== window.top) {
779
+ try {
780
+ if (window.parent.location.hostname.includes("playgama.com")) {
781
+ return true;
782
+ }
783
+ } catch {
784
+ }
785
+ }
786
+ return false;
787
+ } catch {
788
+ return false;
789
+ }
790
+ }
791
+ /**
792
+ * Loads the Playgama Bridge script from CDN and initializes it.
793
+ * Safe to call multiple times - resolves immediately if already initialized.
794
+ */
795
+ async initialize() {
796
+ if (this.initialized) return true;
797
+ try {
798
+ await this.loadScript();
799
+ await window.bridge.initialize();
800
+ this.initialized = true;
801
+ return true;
802
+ } catch (error) {
803
+ console.warn("[PlaygamaService] Failed to initialize:", error);
804
+ return false;
805
+ }
806
+ }
807
+ isInitialized() {
808
+ return this.initialized;
809
+ }
810
+ async showInterstitial() {
811
+ const requestedAt = Date.now();
812
+ if (!this.initialized || !window.bridge) {
813
+ return {
814
+ success: false,
815
+ type: "interstitial",
816
+ error: new Error("Playgama not initialized"),
817
+ requestedAt,
818
+ completedAt: Date.now()
819
+ };
820
+ }
821
+ return new Promise((resolve) => {
822
+ const handler = (state) => {
823
+ if (state === "closed") {
824
+ window.bridge.advertisement.off("interstitial_state_changed", handler);
825
+ resolve({ success: true, type: "interstitial", requestedAt, completedAt: Date.now() });
826
+ } else if (state === "failed") {
827
+ window.bridge.advertisement.off("interstitial_state_changed", handler);
828
+ resolve({
829
+ success: false,
830
+ type: "interstitial",
831
+ error: new Error("Interstitial ad failed"),
832
+ requestedAt,
833
+ completedAt: Date.now()
834
+ });
835
+ }
836
+ };
837
+ window.bridge.advertisement.on("interstitial_state_changed", handler);
838
+ window.bridge.advertisement.showInterstitial();
839
+ });
840
+ }
841
+ async showRewarded() {
842
+ const requestedAt = Date.now();
843
+ if (!this.initialized || !window.bridge) {
844
+ return {
845
+ success: false,
846
+ type: "rewarded",
847
+ error: new Error("Playgama not initialized"),
848
+ requestedAt,
849
+ completedAt: Date.now()
850
+ };
851
+ }
852
+ return new Promise((resolve) => {
853
+ let rewarded = false;
854
+ const handler = (state) => {
855
+ if (state === "rewarded") {
856
+ rewarded = true;
857
+ } else if (state === "closed" || state === "failed") {
858
+ window.bridge.advertisement.off("rewarded_state_changed", handler);
859
+ resolve({
860
+ success: rewarded,
861
+ type: "rewarded",
862
+ error: !rewarded ? new Error("Rewarded ad not completed") : void 0,
863
+ requestedAt,
864
+ completedAt: Date.now()
865
+ });
866
+ }
867
+ };
868
+ window.bridge.advertisement.on("rewarded_state_changed", handler);
869
+ window.bridge.advertisement.showRewarded();
870
+ });
871
+ }
872
+ loadScript() {
873
+ return new Promise((resolve, reject) => {
874
+ if (window.bridge) {
875
+ resolve();
876
+ return;
877
+ }
878
+ const script = document.createElement("script");
879
+ script.src = PLAYGAMA_BRIDGE_CDN;
880
+ script.onload = () => resolve();
881
+ script.onerror = () => reject(new Error("Failed to load Playgama Bridge script"));
882
+ document.head.appendChild(script);
883
+ });
884
+ }
885
+ };
886
+
760
887
  // src/services/billing.ts
761
888
  var BillingPlatform = /* @__PURE__ */ ((BillingPlatform3) => {
762
889
  BillingPlatform3["WEB"] = "web";
@@ -1209,14 +1336,21 @@ var BillingService = class {
1209
1336
  throw new Error("Stripe not initialized");
1210
1337
  }
1211
1338
  try {
1339
+ if (this.checkoutElement) {
1340
+ this.log("info", "[BillingService] Unmounting existing checkout element");
1341
+ this.unmountCheckoutElement();
1342
+ await new Promise((resolve) => setTimeout(resolve, 100));
1343
+ }
1212
1344
  const container = document.getElementById(elementId);
1213
1345
  if (!container) {
1214
1346
  throw new Error(`Element with id "${elementId}" not found in the DOM`);
1215
1347
  }
1216
1348
  container.innerHTML = "";
1349
+ this.log("info", "[BillingService] Creating new checkout instance");
1217
1350
  this.checkoutElement = await this.stripe.initEmbeddedCheckout({
1218
1351
  clientSecret
1219
1352
  });
1353
+ this.log("info", "[BillingService] Mounting checkout element to DOM");
1220
1354
  this.checkoutElement.mount(`#${elementId}`);
1221
1355
  this.setupCheckoutEventListeners();
1222
1356
  } catch (error) {
@@ -1254,7 +1388,14 @@ var BillingService = class {
1254
1388
  */
1255
1389
  unmountCheckoutElement() {
1256
1390
  if (this.checkoutElement) {
1257
- this.checkoutElement.unmount();
1391
+ try {
1392
+ this.checkoutElement.unmount();
1393
+ if (typeof this.checkoutElement.destroy === "function") {
1394
+ this.checkoutElement.destroy();
1395
+ }
1396
+ } catch (error) {
1397
+ this.log("warn", "[BillingService] Error unmounting checkout element:", error?.message);
1398
+ }
1258
1399
  this.checkoutElement = null;
1259
1400
  }
1260
1401
  }
@@ -1454,6 +1595,7 @@ var HyveClient = class {
1454
1595
  jwtToken = null;
1455
1596
  gameId = null;
1456
1597
  adsService;
1598
+ playgamaService = null;
1457
1599
  billingService;
1458
1600
  billingConfig;
1459
1601
  // Store callbacks to preserve them when recreating BillingService
@@ -1481,6 +1623,12 @@ var HyveClient = class {
1481
1623
  if (config?.ads) {
1482
1624
  this.adsService.configure(config.ads);
1483
1625
  }
1626
+ if (typeof window !== "undefined" && PlaygamaService.isPlaygamaDomain()) {
1627
+ this.playgamaService = new PlaygamaService();
1628
+ this.playgamaService.initialize().then((success) => {
1629
+ logger.info("Playgama Bridge initialized:", success);
1630
+ });
1631
+ }
1484
1632
  this.billingConfig = config?.billing || {};
1485
1633
  this.billingService = new BillingService(this.billingConfig);
1486
1634
  this.storageMode = config?.storageMode || "cloud";
@@ -1500,6 +1648,7 @@ var HyveClient = class {
1500
1648
  );
1501
1649
  logger.info("API Base URL:", this.apiBaseUrl);
1502
1650
  logger.info("Ads enabled:", this.adsService.isEnabled());
1651
+ logger.info("Playgama platform:", this.playgamaService !== null);
1503
1652
  logger.info(
1504
1653
  "Billing configured:",
1505
1654
  Object.keys(this.billingConfig).length > 0
@@ -1929,6 +2078,10 @@ var HyveClient = class {
1929
2078
  * @returns Promise resolving to ad result
1930
2079
  */
1931
2080
  async showAd(type) {
2081
+ if (this.playgamaService?.isInitialized()) {
2082
+ if (type === "rewarded") return this.playgamaService.showRewarded();
2083
+ return this.playgamaService.showInterstitial();
2084
+ }
1932
2085
  return this.adsService.show(type);
1933
2086
  }
1934
2087
  /**
@@ -2057,6 +2210,7 @@ export {
2057
2210
  Logger,
2058
2211
  NativeBridge,
2059
2212
  NativeMessageType,
2213
+ PlaygamaService,
2060
2214
  generateUUID,
2061
2215
  handleVerifyMessage,
2062
2216
  isDomainAllowed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyve-sdk/js",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Hyve SDK - TypeScript wrapper for Hyve game server integration",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,6 +15,14 @@
15
15
  "README.md",
16
16
  "LICENSE"
17
17
  ],
18
+ "scripts": {
19
+ "lint": "eslint . --max-warnings 0",
20
+ "check-types": "tsc --noEmit",
21
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
+ "prepublishOnly": "pnpm run build && pnpm run check-types",
23
+ "publish:npm": "pnpm publish --access public",
24
+ "publish:dry-run": "pnpm publish --dry-run --access public --no-git-checks"
25
+ },
18
26
  "keywords": [
19
27
  "hyve",
20
28
  "game",
@@ -48,18 +56,11 @@
48
56
  }
49
57
  },
50
58
  "devDependencies": {
59
+ "@repo/eslint-config": "workspace:*",
60
+ "@repo/typescript-config": "workspace:*",
51
61
  "@types/minimatch": "^5.1.2",
52
62
  "@types/uuid": "^10.0.0",
53
63
  "tsup": "^8.4.0",
54
- "typescript": "^5.3.3",
55
- "@repo/eslint-config": "0.0.0",
56
- "@repo/typescript-config": "0.0.0"
57
- },
58
- "scripts": {
59
- "lint": "eslint . --max-warnings 0",
60
- "check-types": "tsc --noEmit",
61
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
62
- "publish:npm": "pnpm publish --access public",
63
- "publish:dry-run": "pnpm publish --dry-run --access public --no-git-checks"
64
+ "typescript": "^5.3.3"
64
65
  }
65
- }
66
+ }