@hyve-sdk/js 1.3.1-canary.0 → 1.3.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/README.md +95 -0
- package/dist/index.d.mts +139 -3
- package/dist/index.d.ts +139 -3
- package/dist/index.js +226 -1
- package/dist/index.mjs +225 -1
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ pnpm add @hyve-sdk/js
|
|
|
20
20
|
- **API Integration**: Authenticated API calls with JWT token support
|
|
21
21
|
- **Inventory Management**: Built-in methods for user inventory operations
|
|
22
22
|
- **Telemetry Tracking**: Session-based analytics and event tracking
|
|
23
|
+
- **Ads Integration**: Google H5 Games Ads support (disabled by default)
|
|
23
24
|
- **Native Bridge**: Type-safe communication with React Native WebView apps
|
|
24
25
|
- **Security Utilities**: Domain validation and referrer checking
|
|
25
26
|
- **URL Parameter Parsing**: Easy extraction of authentication parameters
|
|
@@ -279,6 +280,100 @@ if (item.metadata) {
|
|
|
279
280
|
- `GET /api/v1/inventory` - Get all inventory items
|
|
280
281
|
- `GET /api/v1/inventory/:id` - Get specific item
|
|
281
282
|
|
|
283
|
+
## Ads Integration
|
|
284
|
+
|
|
285
|
+
The SDK includes support for Google H5 Games Ads. **Ads are disabled by default** and must be explicitly enabled in the configuration.
|
|
286
|
+
|
|
287
|
+
### Quick Start
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { HyveClient } from "@hyve-sdk/js";
|
|
291
|
+
|
|
292
|
+
// Enable ads in initial config
|
|
293
|
+
const client = new HyveClient({
|
|
294
|
+
isDev: true,
|
|
295
|
+
ads: {
|
|
296
|
+
enabled: true, // Must be set to true
|
|
297
|
+
sound: 'on',
|
|
298
|
+
debug: true,
|
|
299
|
+
onBeforeAd: (type) => {
|
|
300
|
+
console.log('Pausing game for ad:', type);
|
|
301
|
+
game.pause();
|
|
302
|
+
},
|
|
303
|
+
onAfterAd: (type) => {
|
|
304
|
+
console.log('Resuming game after ad');
|
|
305
|
+
game.resume();
|
|
306
|
+
},
|
|
307
|
+
onRewardEarned: () => {
|
|
308
|
+
console.log('User earned reward!');
|
|
309
|
+
player.coins += 100;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Show different ad types
|
|
315
|
+
const result = await client.showAd('rewarded');
|
|
316
|
+
if (result.success) {
|
|
317
|
+
console.log('User watched the ad!');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
await client.showAd('interstitial'); // Between levels
|
|
321
|
+
await client.showAd('preroll'); // Game start
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Prerequisites
|
|
325
|
+
|
|
326
|
+
Add the Google H5 Games Ads SDK to your HTML:
|
|
327
|
+
|
|
328
|
+
```html
|
|
329
|
+
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
|
330
|
+
<script>
|
|
331
|
+
window.adBreak = window.adBreak || function(o) {
|
|
332
|
+
(window.adsbygoogle = window.adsbygoogle || []).push(o);
|
|
333
|
+
};
|
|
334
|
+
window.adConfig = window.adConfig || function(o) {
|
|
335
|
+
(window.adsbygoogle = window.adsbygoogle || []).push(o);
|
|
336
|
+
};
|
|
337
|
+
</script>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Ad Types
|
|
341
|
+
|
|
342
|
+
| Type | Use Case |
|
|
343
|
+
|------|----------|
|
|
344
|
+
| `rewarded` | User watches full ad for reward (coins, lives, etc.) |
|
|
345
|
+
| `interstitial` | Between levels or game screens |
|
|
346
|
+
| `preroll` | Before game starts |
|
|
347
|
+
|
|
348
|
+
### Configuration
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
interface AdConfig {
|
|
352
|
+
enabled?: boolean; // Enable/disable ads (default: false)
|
|
353
|
+
sound?: 'on' | 'off'; // Sound setting (default: 'on')
|
|
354
|
+
debug?: boolean; // Enable debug logging (default: false)
|
|
355
|
+
onBeforeAd?: (type) => void; // Called before ad shows
|
|
356
|
+
onAfterAd?: (type) => void; // Called after ad finishes
|
|
357
|
+
onRewardEarned?: () => void; // Called when user earns reward
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Methods
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// Configure ads after initialization
|
|
365
|
+
client.configureAds({ enabled: true, sound: 'off' });
|
|
366
|
+
|
|
367
|
+
// Show an ad
|
|
368
|
+
const result = await client.showAd('rewarded');
|
|
369
|
+
|
|
370
|
+
// Check status
|
|
371
|
+
client.areAdsEnabled(); // Boolean
|
|
372
|
+
client.areAdsReady(); // Boolean
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
See [docs/ads.md](./docs/ads.md) for detailed documentation and examples.
|
|
376
|
+
|
|
282
377
|
**Requirements:**
|
|
283
378
|
- JWT token must be available (via `hyve-access` URL parameter)
|
|
284
379
|
- User must be authenticated
|
package/dist/index.d.mts
CHANGED
|
@@ -63,7 +63,121 @@ interface Inventory {
|
|
|
63
63
|
items: InventoryItem[];
|
|
64
64
|
total_count: number;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Ads configuration options
|
|
68
|
+
* Ads are disabled by default and must be explicitly enabled
|
|
69
|
+
*/
|
|
70
|
+
interface AdConfig$1 {
|
|
71
|
+
/** Enable/disable ads (default: false) */
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
/** Sound setting for ads (default: 'on') */
|
|
74
|
+
sound?: 'on' | 'off';
|
|
75
|
+
/** Enable debug logging (default: false) */
|
|
76
|
+
debug?: boolean;
|
|
77
|
+
/** Callback before ad is shown */
|
|
78
|
+
onBeforeAd?: (type: 'rewarded' | 'interstitial' | 'preroll') => void;
|
|
79
|
+
/** Callback after ad is shown */
|
|
80
|
+
onAfterAd?: (type: 'rewarded' | 'interstitial' | 'preroll') => void;
|
|
81
|
+
/** Callback when user earns a reward (rewarded ads only) */
|
|
82
|
+
onRewardEarned?: () => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Ads Service for Hyve SDK
|
|
87
|
+
*
|
|
88
|
+
* Simple wrapper around Google H5 Games Ads with configurable enable/disable.
|
|
89
|
+
* Ads are OFF by default and must be explicitly enabled in SDK config.
|
|
90
|
+
*
|
|
91
|
+
* Prerequisites:
|
|
92
|
+
* - Google H5 Games Ads SDK script must be loaded in HTML:
|
|
93
|
+
* <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
|
94
|
+
* <script>
|
|
95
|
+
* window.adBreak = window.adBreak || function(o) { (window.adsbygoogle = window.adsbygoogle || []).push(o); };
|
|
96
|
+
* window.adConfig = window.adConfig || function(o) { (window.adsbygoogle = window.adsbygoogle || []).push(o); };
|
|
97
|
+
* </script>
|
|
98
|
+
*
|
|
99
|
+
* @packageDocumentation
|
|
100
|
+
*/
|
|
101
|
+
type AdType = 'rewarded' | 'interstitial' | 'preroll';
|
|
102
|
+
interface AdResult {
|
|
103
|
+
success: boolean;
|
|
104
|
+
type: AdType;
|
|
105
|
+
error?: Error;
|
|
106
|
+
requestedAt: number;
|
|
107
|
+
completedAt: number;
|
|
108
|
+
}
|
|
109
|
+
interface AdConfig {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
sound?: 'on' | 'off';
|
|
112
|
+
debug?: boolean;
|
|
113
|
+
onBeforeAd?: (type: AdType) => void;
|
|
114
|
+
onAfterAd?: (type: AdType) => void;
|
|
115
|
+
onRewardEarned?: () => void;
|
|
116
|
+
}
|
|
117
|
+
interface GoogleAdBreakConfig {
|
|
118
|
+
type: 'reward' | 'next' | 'start';
|
|
119
|
+
name: string;
|
|
120
|
+
beforeAd?: () => void;
|
|
121
|
+
afterAd?: () => void;
|
|
122
|
+
beforeReward?: (showAdFn: () => void) => void;
|
|
123
|
+
adViewed?: () => void;
|
|
124
|
+
adDismissed?: () => void;
|
|
125
|
+
adBreakDone?: (info?: any) => void;
|
|
126
|
+
}
|
|
127
|
+
interface GoogleAdConfigOptions {
|
|
128
|
+
sound?: 'on' | 'off';
|
|
129
|
+
preloadAdBreaks?: 'on' | 'off';
|
|
130
|
+
onReady?: () => void;
|
|
131
|
+
}
|
|
132
|
+
declare global {
|
|
133
|
+
interface Window {
|
|
134
|
+
adBreak?: (config: GoogleAdBreakConfig) => void;
|
|
135
|
+
adConfig?: (config: GoogleAdConfigOptions) => void;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Simple Ads Manager
|
|
140
|
+
* Ads are disabled by default
|
|
141
|
+
*/
|
|
142
|
+
declare class AdsService {
|
|
143
|
+
private config;
|
|
144
|
+
private initialized;
|
|
145
|
+
private ready;
|
|
146
|
+
/**
|
|
147
|
+
* Configure the ads service
|
|
148
|
+
* Must set enabled: true to activate ads
|
|
149
|
+
*/
|
|
150
|
+
configure(config: AdConfig): void;
|
|
151
|
+
/**
|
|
152
|
+
* Initialize the ads system
|
|
153
|
+
*/
|
|
154
|
+
private initialize;
|
|
155
|
+
/**
|
|
156
|
+
* Show an ad
|
|
157
|
+
* Returns immediately if ads are disabled
|
|
158
|
+
*/
|
|
159
|
+
show(type: AdType): Promise<AdResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Show an ad break
|
|
162
|
+
*/
|
|
163
|
+
private showAdBreak;
|
|
164
|
+
/**
|
|
165
|
+
* Check if ads are enabled
|
|
166
|
+
*/
|
|
167
|
+
isEnabled(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Check if ads are ready to show
|
|
170
|
+
*/
|
|
171
|
+
isReady(): boolean;
|
|
172
|
+
}
|
|
66
173
|
|
|
174
|
+
/**
|
|
175
|
+
* HyveClient configuration options
|
|
176
|
+
*/
|
|
177
|
+
interface HyveClientConfig extends TelemetryConfig {
|
|
178
|
+
/** Ads configuration (disabled by default) */
|
|
179
|
+
ads?: AdConfig$1;
|
|
180
|
+
}
|
|
67
181
|
/**
|
|
68
182
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
69
183
|
*/
|
|
@@ -74,11 +188,12 @@ declare class HyveClient {
|
|
|
74
188
|
private userId;
|
|
75
189
|
private jwtToken;
|
|
76
190
|
private gameId;
|
|
191
|
+
private adsService;
|
|
77
192
|
/**
|
|
78
193
|
* Creates a new HyveClient instance
|
|
79
|
-
* @param config Optional telemetry
|
|
194
|
+
* @param config Optional configuration including telemetry and ads
|
|
80
195
|
*/
|
|
81
|
-
constructor(config?:
|
|
196
|
+
constructor(config?: HyveClientConfig);
|
|
82
197
|
/**
|
|
83
198
|
* Authenticates a user from URL parameters
|
|
84
199
|
* @param urlParams URL parameters or search string
|
|
@@ -165,6 +280,27 @@ declare class HyveClient {
|
|
|
165
280
|
* Resets the client state
|
|
166
281
|
*/
|
|
167
282
|
reset(): void;
|
|
283
|
+
/**
|
|
284
|
+
* Configure ads service
|
|
285
|
+
* @param config Ads configuration
|
|
286
|
+
*/
|
|
287
|
+
configureAds(config: AdConfig$1): void;
|
|
288
|
+
/**
|
|
289
|
+
* Show an ad
|
|
290
|
+
* @param type Type of ad to show ('rewarded', 'interstitial', or 'preroll')
|
|
291
|
+
* @returns Promise resolving to ad result
|
|
292
|
+
*/
|
|
293
|
+
showAd(type: AdType): Promise<AdResult>;
|
|
294
|
+
/**
|
|
295
|
+
* Check if ads are enabled
|
|
296
|
+
* @returns Boolean indicating if ads are enabled
|
|
297
|
+
*/
|
|
298
|
+
areAdsEnabled(): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Check if ads are ready to show
|
|
301
|
+
* @returns Boolean indicating if ads are ready
|
|
302
|
+
*/
|
|
303
|
+
areAdsReady(): boolean;
|
|
168
304
|
}
|
|
169
305
|
|
|
170
306
|
/**
|
|
@@ -440,4 +576,4 @@ declare class NativeBridge {
|
|
|
440
576
|
*/
|
|
441
577
|
declare function generateUUID(): string;
|
|
442
578
|
|
|
443
|
-
export { HyveClient, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
|
579
|
+
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -63,7 +63,121 @@ interface Inventory {
|
|
|
63
63
|
items: InventoryItem[];
|
|
64
64
|
total_count: number;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Ads configuration options
|
|
68
|
+
* Ads are disabled by default and must be explicitly enabled
|
|
69
|
+
*/
|
|
70
|
+
interface AdConfig$1 {
|
|
71
|
+
/** Enable/disable ads (default: false) */
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
/** Sound setting for ads (default: 'on') */
|
|
74
|
+
sound?: 'on' | 'off';
|
|
75
|
+
/** Enable debug logging (default: false) */
|
|
76
|
+
debug?: boolean;
|
|
77
|
+
/** Callback before ad is shown */
|
|
78
|
+
onBeforeAd?: (type: 'rewarded' | 'interstitial' | 'preroll') => void;
|
|
79
|
+
/** Callback after ad is shown */
|
|
80
|
+
onAfterAd?: (type: 'rewarded' | 'interstitial' | 'preroll') => void;
|
|
81
|
+
/** Callback when user earns a reward (rewarded ads only) */
|
|
82
|
+
onRewardEarned?: () => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Ads Service for Hyve SDK
|
|
87
|
+
*
|
|
88
|
+
* Simple wrapper around Google H5 Games Ads with configurable enable/disable.
|
|
89
|
+
* Ads are OFF by default and must be explicitly enabled in SDK config.
|
|
90
|
+
*
|
|
91
|
+
* Prerequisites:
|
|
92
|
+
* - Google H5 Games Ads SDK script must be loaded in HTML:
|
|
93
|
+
* <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
|
94
|
+
* <script>
|
|
95
|
+
* window.adBreak = window.adBreak || function(o) { (window.adsbygoogle = window.adsbygoogle || []).push(o); };
|
|
96
|
+
* window.adConfig = window.adConfig || function(o) { (window.adsbygoogle = window.adsbygoogle || []).push(o); };
|
|
97
|
+
* </script>
|
|
98
|
+
*
|
|
99
|
+
* @packageDocumentation
|
|
100
|
+
*/
|
|
101
|
+
type AdType = 'rewarded' | 'interstitial' | 'preroll';
|
|
102
|
+
interface AdResult {
|
|
103
|
+
success: boolean;
|
|
104
|
+
type: AdType;
|
|
105
|
+
error?: Error;
|
|
106
|
+
requestedAt: number;
|
|
107
|
+
completedAt: number;
|
|
108
|
+
}
|
|
109
|
+
interface AdConfig {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
sound?: 'on' | 'off';
|
|
112
|
+
debug?: boolean;
|
|
113
|
+
onBeforeAd?: (type: AdType) => void;
|
|
114
|
+
onAfterAd?: (type: AdType) => void;
|
|
115
|
+
onRewardEarned?: () => void;
|
|
116
|
+
}
|
|
117
|
+
interface GoogleAdBreakConfig {
|
|
118
|
+
type: 'reward' | 'next' | 'start';
|
|
119
|
+
name: string;
|
|
120
|
+
beforeAd?: () => void;
|
|
121
|
+
afterAd?: () => void;
|
|
122
|
+
beforeReward?: (showAdFn: () => void) => void;
|
|
123
|
+
adViewed?: () => void;
|
|
124
|
+
adDismissed?: () => void;
|
|
125
|
+
adBreakDone?: (info?: any) => void;
|
|
126
|
+
}
|
|
127
|
+
interface GoogleAdConfigOptions {
|
|
128
|
+
sound?: 'on' | 'off';
|
|
129
|
+
preloadAdBreaks?: 'on' | 'off';
|
|
130
|
+
onReady?: () => void;
|
|
131
|
+
}
|
|
132
|
+
declare global {
|
|
133
|
+
interface Window {
|
|
134
|
+
adBreak?: (config: GoogleAdBreakConfig) => void;
|
|
135
|
+
adConfig?: (config: GoogleAdConfigOptions) => void;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Simple Ads Manager
|
|
140
|
+
* Ads are disabled by default
|
|
141
|
+
*/
|
|
142
|
+
declare class AdsService {
|
|
143
|
+
private config;
|
|
144
|
+
private initialized;
|
|
145
|
+
private ready;
|
|
146
|
+
/**
|
|
147
|
+
* Configure the ads service
|
|
148
|
+
* Must set enabled: true to activate ads
|
|
149
|
+
*/
|
|
150
|
+
configure(config: AdConfig): void;
|
|
151
|
+
/**
|
|
152
|
+
* Initialize the ads system
|
|
153
|
+
*/
|
|
154
|
+
private initialize;
|
|
155
|
+
/**
|
|
156
|
+
* Show an ad
|
|
157
|
+
* Returns immediately if ads are disabled
|
|
158
|
+
*/
|
|
159
|
+
show(type: AdType): Promise<AdResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Show an ad break
|
|
162
|
+
*/
|
|
163
|
+
private showAdBreak;
|
|
164
|
+
/**
|
|
165
|
+
* Check if ads are enabled
|
|
166
|
+
*/
|
|
167
|
+
isEnabled(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Check if ads are ready to show
|
|
170
|
+
*/
|
|
171
|
+
isReady(): boolean;
|
|
172
|
+
}
|
|
66
173
|
|
|
174
|
+
/**
|
|
175
|
+
* HyveClient configuration options
|
|
176
|
+
*/
|
|
177
|
+
interface HyveClientConfig extends TelemetryConfig {
|
|
178
|
+
/** Ads configuration (disabled by default) */
|
|
179
|
+
ads?: AdConfig$1;
|
|
180
|
+
}
|
|
67
181
|
/**
|
|
68
182
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
69
183
|
*/
|
|
@@ -74,11 +188,12 @@ declare class HyveClient {
|
|
|
74
188
|
private userId;
|
|
75
189
|
private jwtToken;
|
|
76
190
|
private gameId;
|
|
191
|
+
private adsService;
|
|
77
192
|
/**
|
|
78
193
|
* Creates a new HyveClient instance
|
|
79
|
-
* @param config Optional telemetry
|
|
194
|
+
* @param config Optional configuration including telemetry and ads
|
|
80
195
|
*/
|
|
81
|
-
constructor(config?:
|
|
196
|
+
constructor(config?: HyveClientConfig);
|
|
82
197
|
/**
|
|
83
198
|
* Authenticates a user from URL parameters
|
|
84
199
|
* @param urlParams URL parameters or search string
|
|
@@ -165,6 +280,27 @@ declare class HyveClient {
|
|
|
165
280
|
* Resets the client state
|
|
166
281
|
*/
|
|
167
282
|
reset(): void;
|
|
283
|
+
/**
|
|
284
|
+
* Configure ads service
|
|
285
|
+
* @param config Ads configuration
|
|
286
|
+
*/
|
|
287
|
+
configureAds(config: AdConfig$1): void;
|
|
288
|
+
/**
|
|
289
|
+
* Show an ad
|
|
290
|
+
* @param type Type of ad to show ('rewarded', 'interstitial', or 'preroll')
|
|
291
|
+
* @returns Promise resolving to ad result
|
|
292
|
+
*/
|
|
293
|
+
showAd(type: AdType): Promise<AdResult>;
|
|
294
|
+
/**
|
|
295
|
+
* Check if ads are enabled
|
|
296
|
+
* @returns Boolean indicating if ads are enabled
|
|
297
|
+
*/
|
|
298
|
+
areAdsEnabled(): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Check if ads are ready to show
|
|
301
|
+
* @returns Boolean indicating if ads are ready
|
|
302
|
+
*/
|
|
303
|
+
areAdsReady(): boolean;
|
|
168
304
|
}
|
|
169
305
|
|
|
170
306
|
/**
|
|
@@ -440,4 +576,4 @@ declare class NativeBridge {
|
|
|
440
576
|
*/
|
|
441
577
|
declare function generateUUID(): string;
|
|
442
578
|
|
|
443
|
-
export { HyveClient, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
|
579
|
+
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AdsService: () => AdsService,
|
|
23
24
|
HyveClient: () => HyveClient,
|
|
24
25
|
Logger: () => Logger,
|
|
25
26
|
NativeBridge: () => NativeBridge,
|
|
@@ -520,6 +521,193 @@ function generateUUID() {
|
|
|
520
521
|
return (0, import_uuid.v4)();
|
|
521
522
|
}
|
|
522
523
|
|
|
524
|
+
// src/services/ads.ts
|
|
525
|
+
var AdsService = class {
|
|
526
|
+
config = {
|
|
527
|
+
enabled: false,
|
|
528
|
+
sound: "on",
|
|
529
|
+
debug: false,
|
|
530
|
+
onBeforeAd: () => {
|
|
531
|
+
},
|
|
532
|
+
onAfterAd: () => {
|
|
533
|
+
},
|
|
534
|
+
onRewardEarned: () => {
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
initialized = false;
|
|
538
|
+
ready = false;
|
|
539
|
+
/**
|
|
540
|
+
* Configure the ads service
|
|
541
|
+
* Must set enabled: true to activate ads
|
|
542
|
+
*/
|
|
543
|
+
configure(config) {
|
|
544
|
+
this.config = {
|
|
545
|
+
...this.config,
|
|
546
|
+
...config,
|
|
547
|
+
onBeforeAd: config.onBeforeAd || this.config.onBeforeAd,
|
|
548
|
+
onAfterAd: config.onAfterAd || this.config.onAfterAd,
|
|
549
|
+
onRewardEarned: config.onRewardEarned || this.config.onRewardEarned
|
|
550
|
+
};
|
|
551
|
+
if (this.config.debug) {
|
|
552
|
+
console.log("[AdsService] Configuration updated:", {
|
|
553
|
+
enabled: this.config.enabled,
|
|
554
|
+
sound: this.config.sound
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
if (this.config.enabled && !this.initialized) {
|
|
558
|
+
this.initialize();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Initialize the ads system
|
|
563
|
+
*/
|
|
564
|
+
initialize() {
|
|
565
|
+
if (this.initialized) return;
|
|
566
|
+
if (!this.config.enabled) {
|
|
567
|
+
if (this.config.debug) {
|
|
568
|
+
console.log("[AdsService] Ads disabled, skipping initialization");
|
|
569
|
+
}
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (!window.adConfig || !window.adBreak) {
|
|
573
|
+
console.warn("[AdsService] Google Ads SDK not found. Ads will not be available.");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (this.config.debug) {
|
|
577
|
+
console.log("[AdsService] Initializing ads system...");
|
|
578
|
+
}
|
|
579
|
+
const googleConfig = {
|
|
580
|
+
sound: this.config.sound,
|
|
581
|
+
preloadAdBreaks: "on",
|
|
582
|
+
onReady: () => {
|
|
583
|
+
this.ready = true;
|
|
584
|
+
if (this.config.debug) {
|
|
585
|
+
console.log("[AdsService] Ads ready");
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
window.adConfig(googleConfig);
|
|
590
|
+
this.initialized = true;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Show an ad
|
|
594
|
+
* Returns immediately if ads are disabled
|
|
595
|
+
*/
|
|
596
|
+
async show(type) {
|
|
597
|
+
const requestedAt = Date.now();
|
|
598
|
+
if (!this.config.enabled) {
|
|
599
|
+
if (this.config.debug) {
|
|
600
|
+
console.log("[AdsService] Ads disabled, skipping ad request");
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
success: false,
|
|
604
|
+
type,
|
|
605
|
+
error: new Error("Ads are disabled"),
|
|
606
|
+
requestedAt,
|
|
607
|
+
completedAt: Date.now()
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
if (!this.initialized) {
|
|
611
|
+
this.initialize();
|
|
612
|
+
}
|
|
613
|
+
if (!this.ready || !window.adBreak) {
|
|
614
|
+
return {
|
|
615
|
+
success: false,
|
|
616
|
+
type,
|
|
617
|
+
error: new Error("Ads not ready"),
|
|
618
|
+
requestedAt,
|
|
619
|
+
completedAt: Date.now()
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
return this.showAdBreak(type);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Show an ad break
|
|
626
|
+
*/
|
|
627
|
+
async showAdBreak(type) {
|
|
628
|
+
const requestedAt = Date.now();
|
|
629
|
+
return new Promise((resolve) => {
|
|
630
|
+
const googleType = type === "rewarded" ? "reward" : type === "preroll" ? "start" : "next";
|
|
631
|
+
const adName = `${type}-ad-${Date.now()}`;
|
|
632
|
+
if (this.config.debug) {
|
|
633
|
+
console.log(`[AdsService] Showing ${type} ad`);
|
|
634
|
+
}
|
|
635
|
+
this.config.onBeforeAd(type);
|
|
636
|
+
const adBreakConfig = {
|
|
637
|
+
type: googleType,
|
|
638
|
+
name: adName,
|
|
639
|
+
beforeAd: () => {
|
|
640
|
+
if (this.config.debug) {
|
|
641
|
+
console.log("[AdsService] Ad started");
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
afterAd: () => {
|
|
645
|
+
if (this.config.debug) {
|
|
646
|
+
console.log("[AdsService] Ad finished");
|
|
647
|
+
}
|
|
648
|
+
this.config.onAfterAd(type);
|
|
649
|
+
},
|
|
650
|
+
adBreakDone: (info) => {
|
|
651
|
+
const completedAt = Date.now();
|
|
652
|
+
let success = false;
|
|
653
|
+
if (type === "rewarded") {
|
|
654
|
+
success = info?.breakStatus === "viewed";
|
|
655
|
+
} else {
|
|
656
|
+
success = info?.breakStatus !== "error";
|
|
657
|
+
}
|
|
658
|
+
const error = info?.breakStatus === "error" && info?.error ? new Error(info.error) : void 0;
|
|
659
|
+
if (this.config.debug) {
|
|
660
|
+
console.log("[AdsService] Ad break done:", {
|
|
661
|
+
success,
|
|
662
|
+
status: info?.breakStatus
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
const result = {
|
|
666
|
+
success,
|
|
667
|
+
type,
|
|
668
|
+
error,
|
|
669
|
+
requestedAt,
|
|
670
|
+
completedAt
|
|
671
|
+
};
|
|
672
|
+
resolve(result);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
if (type === "rewarded") {
|
|
676
|
+
adBreakConfig.beforeReward = (showAdFn) => {
|
|
677
|
+
if (this.config.debug) {
|
|
678
|
+
console.log("[AdsService] beforeReward callback");
|
|
679
|
+
}
|
|
680
|
+
showAdFn();
|
|
681
|
+
};
|
|
682
|
+
adBreakConfig.adViewed = () => {
|
|
683
|
+
if (this.config.debug) {
|
|
684
|
+
console.log("[AdsService] Rewarded ad watched successfully");
|
|
685
|
+
}
|
|
686
|
+
this.config.onRewardEarned();
|
|
687
|
+
};
|
|
688
|
+
adBreakConfig.adDismissed = () => {
|
|
689
|
+
if (this.config.debug) {
|
|
690
|
+
console.log("[AdsService] Rewarded ad dismissed");
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
window.adBreak(adBreakConfig);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Check if ads are enabled
|
|
699
|
+
*/
|
|
700
|
+
isEnabled() {
|
|
701
|
+
return this.config.enabled;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Check if ads are ready to show
|
|
705
|
+
*/
|
|
706
|
+
isReady() {
|
|
707
|
+
return this.config.enabled && this.ready;
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
523
711
|
// src/core/client.ts
|
|
524
712
|
var HyveClient = class {
|
|
525
713
|
telemetryConfig;
|
|
@@ -528,9 +716,10 @@ var HyveClient = class {
|
|
|
528
716
|
userId = null;
|
|
529
717
|
jwtToken = null;
|
|
530
718
|
gameId = null;
|
|
719
|
+
adsService;
|
|
531
720
|
/**
|
|
532
721
|
* Creates a new HyveClient instance
|
|
533
|
-
* @param config Optional telemetry
|
|
722
|
+
* @param config Optional configuration including telemetry and ads
|
|
534
723
|
*/
|
|
535
724
|
constructor(config) {
|
|
536
725
|
this.telemetryConfig = {
|
|
@@ -544,9 +733,14 @@ var HyveClient = class {
|
|
|
544
733
|
this.apiBaseUrl = this.telemetryConfig.isDev ? "https://product-api.dev.hyve.gg" : "https://product-api.prod.hyve.gg";
|
|
545
734
|
}
|
|
546
735
|
this.sessionId = generateUUID();
|
|
736
|
+
this.adsService = new AdsService();
|
|
737
|
+
if (config?.ads) {
|
|
738
|
+
this.adsService.configure(config.ads);
|
|
739
|
+
}
|
|
547
740
|
logger.info("Client initialized with sessionId:", this.sessionId);
|
|
548
741
|
logger.info("API Base URL:", this.apiBaseUrl);
|
|
549
742
|
logger.info("Environment:", this.telemetryConfig.isDev ? "dev" : "prod");
|
|
743
|
+
logger.info("Ads enabled:", this.adsService.isEnabled());
|
|
550
744
|
}
|
|
551
745
|
/**
|
|
552
746
|
* Authenticates a user from URL parameters
|
|
@@ -794,9 +988,40 @@ var HyveClient = class {
|
|
|
794
988
|
this.sessionId = generateUUID();
|
|
795
989
|
logger.info("Client reset with new sessionId:", this.sessionId);
|
|
796
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* Configure ads service
|
|
993
|
+
* @param config Ads configuration
|
|
994
|
+
*/
|
|
995
|
+
configureAds(config) {
|
|
996
|
+
this.adsService.configure(config);
|
|
997
|
+
logger.info("Ads configuration updated");
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Show an ad
|
|
1001
|
+
* @param type Type of ad to show ('rewarded', 'interstitial', or 'preroll')
|
|
1002
|
+
* @returns Promise resolving to ad result
|
|
1003
|
+
*/
|
|
1004
|
+
async showAd(type) {
|
|
1005
|
+
return this.adsService.show(type);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Check if ads are enabled
|
|
1009
|
+
* @returns Boolean indicating if ads are enabled
|
|
1010
|
+
*/
|
|
1011
|
+
areAdsEnabled() {
|
|
1012
|
+
return this.adsService.isEnabled();
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Check if ads are ready to show
|
|
1016
|
+
* @returns Boolean indicating if ads are ready
|
|
1017
|
+
*/
|
|
1018
|
+
areAdsReady() {
|
|
1019
|
+
return this.adsService.isReady();
|
|
1020
|
+
}
|
|
797
1021
|
};
|
|
798
1022
|
// Annotate the CommonJS export names for ESM import in node:
|
|
799
1023
|
0 && (module.exports = {
|
|
1024
|
+
AdsService,
|
|
800
1025
|
HyveClient,
|
|
801
1026
|
Logger,
|
|
802
1027
|
NativeBridge,
|
package/dist/index.mjs
CHANGED
|
@@ -483,6 +483,193 @@ function generateUUID() {
|
|
|
483
483
|
return uuidv4();
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
+
// src/services/ads.ts
|
|
487
|
+
var AdsService = class {
|
|
488
|
+
config = {
|
|
489
|
+
enabled: false,
|
|
490
|
+
sound: "on",
|
|
491
|
+
debug: false,
|
|
492
|
+
onBeforeAd: () => {
|
|
493
|
+
},
|
|
494
|
+
onAfterAd: () => {
|
|
495
|
+
},
|
|
496
|
+
onRewardEarned: () => {
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
initialized = false;
|
|
500
|
+
ready = false;
|
|
501
|
+
/**
|
|
502
|
+
* Configure the ads service
|
|
503
|
+
* Must set enabled: true to activate ads
|
|
504
|
+
*/
|
|
505
|
+
configure(config) {
|
|
506
|
+
this.config = {
|
|
507
|
+
...this.config,
|
|
508
|
+
...config,
|
|
509
|
+
onBeforeAd: config.onBeforeAd || this.config.onBeforeAd,
|
|
510
|
+
onAfterAd: config.onAfterAd || this.config.onAfterAd,
|
|
511
|
+
onRewardEarned: config.onRewardEarned || this.config.onRewardEarned
|
|
512
|
+
};
|
|
513
|
+
if (this.config.debug) {
|
|
514
|
+
console.log("[AdsService] Configuration updated:", {
|
|
515
|
+
enabled: this.config.enabled,
|
|
516
|
+
sound: this.config.sound
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
if (this.config.enabled && !this.initialized) {
|
|
520
|
+
this.initialize();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Initialize the ads system
|
|
525
|
+
*/
|
|
526
|
+
initialize() {
|
|
527
|
+
if (this.initialized) return;
|
|
528
|
+
if (!this.config.enabled) {
|
|
529
|
+
if (this.config.debug) {
|
|
530
|
+
console.log("[AdsService] Ads disabled, skipping initialization");
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (!window.adConfig || !window.adBreak) {
|
|
535
|
+
console.warn("[AdsService] Google Ads SDK not found. Ads will not be available.");
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (this.config.debug) {
|
|
539
|
+
console.log("[AdsService] Initializing ads system...");
|
|
540
|
+
}
|
|
541
|
+
const googleConfig = {
|
|
542
|
+
sound: this.config.sound,
|
|
543
|
+
preloadAdBreaks: "on",
|
|
544
|
+
onReady: () => {
|
|
545
|
+
this.ready = true;
|
|
546
|
+
if (this.config.debug) {
|
|
547
|
+
console.log("[AdsService] Ads ready");
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
window.adConfig(googleConfig);
|
|
552
|
+
this.initialized = true;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Show an ad
|
|
556
|
+
* Returns immediately if ads are disabled
|
|
557
|
+
*/
|
|
558
|
+
async show(type) {
|
|
559
|
+
const requestedAt = Date.now();
|
|
560
|
+
if (!this.config.enabled) {
|
|
561
|
+
if (this.config.debug) {
|
|
562
|
+
console.log("[AdsService] Ads disabled, skipping ad request");
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
success: false,
|
|
566
|
+
type,
|
|
567
|
+
error: new Error("Ads are disabled"),
|
|
568
|
+
requestedAt,
|
|
569
|
+
completedAt: Date.now()
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
if (!this.initialized) {
|
|
573
|
+
this.initialize();
|
|
574
|
+
}
|
|
575
|
+
if (!this.ready || !window.adBreak) {
|
|
576
|
+
return {
|
|
577
|
+
success: false,
|
|
578
|
+
type,
|
|
579
|
+
error: new Error("Ads not ready"),
|
|
580
|
+
requestedAt,
|
|
581
|
+
completedAt: Date.now()
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
return this.showAdBreak(type);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Show an ad break
|
|
588
|
+
*/
|
|
589
|
+
async showAdBreak(type) {
|
|
590
|
+
const requestedAt = Date.now();
|
|
591
|
+
return new Promise((resolve) => {
|
|
592
|
+
const googleType = type === "rewarded" ? "reward" : type === "preroll" ? "start" : "next";
|
|
593
|
+
const adName = `${type}-ad-${Date.now()}`;
|
|
594
|
+
if (this.config.debug) {
|
|
595
|
+
console.log(`[AdsService] Showing ${type} ad`);
|
|
596
|
+
}
|
|
597
|
+
this.config.onBeforeAd(type);
|
|
598
|
+
const adBreakConfig = {
|
|
599
|
+
type: googleType,
|
|
600
|
+
name: adName,
|
|
601
|
+
beforeAd: () => {
|
|
602
|
+
if (this.config.debug) {
|
|
603
|
+
console.log("[AdsService] Ad started");
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
afterAd: () => {
|
|
607
|
+
if (this.config.debug) {
|
|
608
|
+
console.log("[AdsService] Ad finished");
|
|
609
|
+
}
|
|
610
|
+
this.config.onAfterAd(type);
|
|
611
|
+
},
|
|
612
|
+
adBreakDone: (info) => {
|
|
613
|
+
const completedAt = Date.now();
|
|
614
|
+
let success = false;
|
|
615
|
+
if (type === "rewarded") {
|
|
616
|
+
success = info?.breakStatus === "viewed";
|
|
617
|
+
} else {
|
|
618
|
+
success = info?.breakStatus !== "error";
|
|
619
|
+
}
|
|
620
|
+
const error = info?.breakStatus === "error" && info?.error ? new Error(info.error) : void 0;
|
|
621
|
+
if (this.config.debug) {
|
|
622
|
+
console.log("[AdsService] Ad break done:", {
|
|
623
|
+
success,
|
|
624
|
+
status: info?.breakStatus
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
const result = {
|
|
628
|
+
success,
|
|
629
|
+
type,
|
|
630
|
+
error,
|
|
631
|
+
requestedAt,
|
|
632
|
+
completedAt
|
|
633
|
+
};
|
|
634
|
+
resolve(result);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
if (type === "rewarded") {
|
|
638
|
+
adBreakConfig.beforeReward = (showAdFn) => {
|
|
639
|
+
if (this.config.debug) {
|
|
640
|
+
console.log("[AdsService] beforeReward callback");
|
|
641
|
+
}
|
|
642
|
+
showAdFn();
|
|
643
|
+
};
|
|
644
|
+
adBreakConfig.adViewed = () => {
|
|
645
|
+
if (this.config.debug) {
|
|
646
|
+
console.log("[AdsService] Rewarded ad watched successfully");
|
|
647
|
+
}
|
|
648
|
+
this.config.onRewardEarned();
|
|
649
|
+
};
|
|
650
|
+
adBreakConfig.adDismissed = () => {
|
|
651
|
+
if (this.config.debug) {
|
|
652
|
+
console.log("[AdsService] Rewarded ad dismissed");
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
window.adBreak(adBreakConfig);
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Check if ads are enabled
|
|
661
|
+
*/
|
|
662
|
+
isEnabled() {
|
|
663
|
+
return this.config.enabled;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Check if ads are ready to show
|
|
667
|
+
*/
|
|
668
|
+
isReady() {
|
|
669
|
+
return this.config.enabled && this.ready;
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
|
|
486
673
|
// src/core/client.ts
|
|
487
674
|
var HyveClient = class {
|
|
488
675
|
telemetryConfig;
|
|
@@ -491,9 +678,10 @@ var HyveClient = class {
|
|
|
491
678
|
userId = null;
|
|
492
679
|
jwtToken = null;
|
|
493
680
|
gameId = null;
|
|
681
|
+
adsService;
|
|
494
682
|
/**
|
|
495
683
|
* Creates a new HyveClient instance
|
|
496
|
-
* @param config Optional telemetry
|
|
684
|
+
* @param config Optional configuration including telemetry and ads
|
|
497
685
|
*/
|
|
498
686
|
constructor(config) {
|
|
499
687
|
this.telemetryConfig = {
|
|
@@ -507,9 +695,14 @@ var HyveClient = class {
|
|
|
507
695
|
this.apiBaseUrl = this.telemetryConfig.isDev ? "https://product-api.dev.hyve.gg" : "https://product-api.prod.hyve.gg";
|
|
508
696
|
}
|
|
509
697
|
this.sessionId = generateUUID();
|
|
698
|
+
this.adsService = new AdsService();
|
|
699
|
+
if (config?.ads) {
|
|
700
|
+
this.adsService.configure(config.ads);
|
|
701
|
+
}
|
|
510
702
|
logger.info("Client initialized with sessionId:", this.sessionId);
|
|
511
703
|
logger.info("API Base URL:", this.apiBaseUrl);
|
|
512
704
|
logger.info("Environment:", this.telemetryConfig.isDev ? "dev" : "prod");
|
|
705
|
+
logger.info("Ads enabled:", this.adsService.isEnabled());
|
|
513
706
|
}
|
|
514
707
|
/**
|
|
515
708
|
* Authenticates a user from URL parameters
|
|
@@ -757,8 +950,39 @@ var HyveClient = class {
|
|
|
757
950
|
this.sessionId = generateUUID();
|
|
758
951
|
logger.info("Client reset with new sessionId:", this.sessionId);
|
|
759
952
|
}
|
|
953
|
+
/**
|
|
954
|
+
* Configure ads service
|
|
955
|
+
* @param config Ads configuration
|
|
956
|
+
*/
|
|
957
|
+
configureAds(config) {
|
|
958
|
+
this.adsService.configure(config);
|
|
959
|
+
logger.info("Ads configuration updated");
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Show an ad
|
|
963
|
+
* @param type Type of ad to show ('rewarded', 'interstitial', or 'preroll')
|
|
964
|
+
* @returns Promise resolving to ad result
|
|
965
|
+
*/
|
|
966
|
+
async showAd(type) {
|
|
967
|
+
return this.adsService.show(type);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Check if ads are enabled
|
|
971
|
+
* @returns Boolean indicating if ads are enabled
|
|
972
|
+
*/
|
|
973
|
+
areAdsEnabled() {
|
|
974
|
+
return this.adsService.isEnabled();
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Check if ads are ready to show
|
|
978
|
+
* @returns Boolean indicating if ads are ready
|
|
979
|
+
*/
|
|
980
|
+
areAdsReady() {
|
|
981
|
+
return this.adsService.isReady();
|
|
982
|
+
}
|
|
760
983
|
};
|
|
761
984
|
export {
|
|
985
|
+
AdsService,
|
|
762
986
|
HyveClient,
|
|
763
987
|
Logger,
|
|
764
988
|
NativeBridge,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyve-sdk/js",
|
|
3
|
-
"version": "1.3.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Hyve SDK - TypeScript wrapper for Hyve game server integration",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,14 +15,6 @@
|
|
|
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
|
-
},
|
|
26
18
|
"keywords": [
|
|
27
19
|
"hyve",
|
|
28
20
|
"game",
|
|
@@ -48,11 +40,18 @@
|
|
|
48
40
|
"uuid": "^10.0.0"
|
|
49
41
|
},
|
|
50
42
|
"devDependencies": {
|
|
51
|
-
"@repo/eslint-config": "workspace:*",
|
|
52
|
-
"@repo/typescript-config": "workspace:*",
|
|
53
43
|
"@types/minimatch": "^5.1.2",
|
|
54
44
|
"@types/uuid": "^10.0.0",
|
|
55
45
|
"tsup": "^8.4.0",
|
|
56
|
-
"typescript": "^5.3.3"
|
|
46
|
+
"typescript": "^5.3.3",
|
|
47
|
+
"@repo/typescript-config": "0.0.0",
|
|
48
|
+
"@repo/eslint-config": "0.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"lint": "eslint . --max-warnings 0",
|
|
52
|
+
"check-types": "tsc --noEmit",
|
|
53
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
54
|
+
"publish:npm": "pnpm publish --access public",
|
|
55
|
+
"publish:dry-run": "pnpm publish --dry-run --access public --no-git-checks"
|
|
57
56
|
}
|
|
58
|
-
}
|
|
57
|
+
}
|