@thestatic-tv/dcl-sdk 1.0.3 → 1.0.5

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
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Player identity data from DCL
3
+ */
4
+ interface PlayerData {
5
+ /** Player's wallet address (userId from DCL) */
6
+ wallet?: string;
7
+ /** Player's display name */
8
+ name?: string;
9
+ }
1
10
  /**
2
11
  * Configuration options for StaticTVClient
3
12
  */
@@ -14,6 +23,17 @@ interface StaticTVConfig {
14
23
  debug?: boolean;
15
24
  /** Custom API base URL (default: https://thestatic.tv/api/v1/dcl) */
16
25
  baseUrl?: string;
26
+ /**
27
+ * Player data from DCL - pass from your scene's getPlayer() call
28
+ * @example
29
+ * import { getPlayer } from '@dcl/sdk/players'
30
+ * const player = getPlayer()
31
+ * new StaticTVClient({
32
+ * apiKey: 'dcls_...',
33
+ * player: { wallet: player?.userId, name: player?.name }
34
+ * })
35
+ */
36
+ player?: PlayerData;
17
37
  }
18
38
  /**
19
39
  * Channel information from the guide
@@ -155,6 +175,14 @@ declare class SessionModule {
155
175
  * Get the appropriate session endpoint based on key type
156
176
  */
157
177
  private getEndpoint;
178
+ /**
179
+ * Get player wallet - prioritize config, fallback to runtime detection
180
+ */
181
+ private getWallet;
182
+ /**
183
+ * Get player display name - prioritize config, fallback to runtime detection
184
+ */
185
+ private getDisplayName;
158
186
  /**
159
187
  * Start a new session
160
188
  * Called automatically if autoStartSession is true
@@ -208,6 +236,10 @@ declare class HeartbeatModule {
208
236
  * Stop tracking video watching
209
237
  */
210
238
  stopWatching(): void;
239
+ /**
240
+ * Get player wallet - prioritize config, fallback to runtime detection
241
+ */
242
+ private getWallet;
211
243
  /**
212
244
  * Send a watching heartbeat (1 heartbeat = 1 minute watched)
213
245
  */
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Player identity data from DCL
3
+ */
4
+ interface PlayerData {
5
+ /** Player's wallet address (userId from DCL) */
6
+ wallet?: string;
7
+ /** Player's display name */
8
+ name?: string;
9
+ }
1
10
  /**
2
11
  * Configuration options for StaticTVClient
3
12
  */
@@ -14,6 +23,17 @@ interface StaticTVConfig {
14
23
  debug?: boolean;
15
24
  /** Custom API base URL (default: https://thestatic.tv/api/v1/dcl) */
16
25
  baseUrl?: string;
26
+ /**
27
+ * Player data from DCL - pass from your scene's getPlayer() call
28
+ * @example
29
+ * import { getPlayer } from '@dcl/sdk/players'
30
+ * const player = getPlayer()
31
+ * new StaticTVClient({
32
+ * apiKey: 'dcls_...',
33
+ * player: { wallet: player?.userId, name: player?.name }
34
+ * })
35
+ */
36
+ player?: PlayerData;
17
37
  }
18
38
  /**
19
39
  * Channel information from the guide
@@ -155,6 +175,14 @@ declare class SessionModule {
155
175
  * Get the appropriate session endpoint based on key type
156
176
  */
157
177
  private getEndpoint;
178
+ /**
179
+ * Get player wallet - prioritize config, fallback to runtime detection
180
+ */
181
+ private getWallet;
182
+ /**
183
+ * Get player display name - prioritize config, fallback to runtime detection
184
+ */
185
+ private getDisplayName;
158
186
  /**
159
187
  * Start a new session
160
188
  * Called automatically if autoStartSession is true
@@ -208,6 +236,10 @@ declare class HeartbeatModule {
208
236
  * Stop tracking video watching
209
237
  */
210
238
  stopWatching(): void;
239
+ /**
240
+ * Get player wallet - prioritize config, fallback to runtime detection
241
+ */
242
+ private getWallet;
211
243
  /**
212
244
  * Send a watching heartbeat (1 heartbeat = 1 minute watched)
213
245
  */
package/dist/index.js CHANGED
@@ -173,6 +173,20 @@ var SessionModule = class {
173
173
  getEndpoint() {
174
174
  return this.client.isLite ? "/scene-session" : "/session";
175
175
  }
176
+ /**
177
+ * Get player wallet - prioritize config, fallback to runtime detection
178
+ */
179
+ getWallet() {
180
+ const config = this.client.getConfig();
181
+ return config.player?.wallet || getPlayerWallet();
182
+ }
183
+ /**
184
+ * Get player display name - prioritize config, fallback to runtime detection
185
+ */
186
+ getDisplayName() {
187
+ const config = this.client.getConfig();
188
+ return config.player?.name || getPlayerDisplayName();
189
+ }
176
190
  /**
177
191
  * Start a new session
178
192
  * Called automatically if autoStartSession is true
@@ -183,12 +197,15 @@ var SessionModule = class {
183
197
  return this.sessionId;
184
198
  }
185
199
  try {
200
+ const walletAddress = this.getWallet();
201
+ const dclDisplayName = this.getDisplayName();
202
+ this.client.log(`Starting session with wallet: ${walletAddress}, name: ${dclDisplayName}`);
186
203
  const response = await this.client.request(this.getEndpoint(), {
187
204
  method: "POST",
188
205
  body: JSON.stringify({
189
206
  action: "enter",
190
- walletAddress: getPlayerWallet(),
191
- dclDisplayName: getPlayerDisplayName(),
207
+ walletAddress,
208
+ dclDisplayName,
192
209
  metadata
193
210
  })
194
211
  });
@@ -277,7 +294,7 @@ var SessionModule = class {
277
294
  */
278
295
  async getStats() {
279
296
  try {
280
- const wallet = getPlayerWallet();
297
+ const wallet = this.getWallet();
281
298
  const queryParam = wallet ? `?wallet=${wallet}` : "";
282
299
  const response = await this.client.request(
283
300
  `/scene-stats${queryParam}`,
@@ -339,6 +356,13 @@ var HeartbeatModule = class {
339
356
  this.currentChannel = null;
340
357
  this.isWatching = false;
341
358
  }
359
+ /**
360
+ * Get player wallet - prioritize config, fallback to runtime detection
361
+ */
362
+ getWallet() {
363
+ const config = this.client.getConfig();
364
+ return config.player?.wallet || getPlayerWallet();
365
+ }
342
366
  /**
343
367
  * Send a watching heartbeat (1 heartbeat = 1 minute watched)
344
368
  */
@@ -350,7 +374,7 @@ var HeartbeatModule = class {
350
374
  method: "POST",
351
375
  body: JSON.stringify({
352
376
  channelSlug: this.currentChannel,
353
- walletAddress: getPlayerWallet(),
377
+ walletAddress: this.getWallet(),
354
378
  sessionId
355
379
  })
356
380
  });
package/dist/index.mjs CHANGED
@@ -148,6 +148,20 @@ var SessionModule = class {
148
148
  getEndpoint() {
149
149
  return this.client.isLite ? "/scene-session" : "/session";
150
150
  }
151
+ /**
152
+ * Get player wallet - prioritize config, fallback to runtime detection
153
+ */
154
+ getWallet() {
155
+ const config = this.client.getConfig();
156
+ return config.player?.wallet || getPlayerWallet();
157
+ }
158
+ /**
159
+ * Get player display name - prioritize config, fallback to runtime detection
160
+ */
161
+ getDisplayName() {
162
+ const config = this.client.getConfig();
163
+ return config.player?.name || getPlayerDisplayName();
164
+ }
151
165
  /**
152
166
  * Start a new session
153
167
  * Called automatically if autoStartSession is true
@@ -158,12 +172,15 @@ var SessionModule = class {
158
172
  return this.sessionId;
159
173
  }
160
174
  try {
175
+ const walletAddress = this.getWallet();
176
+ const dclDisplayName = this.getDisplayName();
177
+ this.client.log(`Starting session with wallet: ${walletAddress}, name: ${dclDisplayName}`);
161
178
  const response = await this.client.request(this.getEndpoint(), {
162
179
  method: "POST",
163
180
  body: JSON.stringify({
164
181
  action: "enter",
165
- walletAddress: getPlayerWallet(),
166
- dclDisplayName: getPlayerDisplayName(),
182
+ walletAddress,
183
+ dclDisplayName,
167
184
  metadata
168
185
  })
169
186
  });
@@ -252,7 +269,7 @@ var SessionModule = class {
252
269
  */
253
270
  async getStats() {
254
271
  try {
255
- const wallet = getPlayerWallet();
272
+ const wallet = this.getWallet();
256
273
  const queryParam = wallet ? `?wallet=${wallet}` : "";
257
274
  const response = await this.client.request(
258
275
  `/scene-stats${queryParam}`,
@@ -314,6 +331,13 @@ var HeartbeatModule = class {
314
331
  this.currentChannel = null;
315
332
  this.isWatching = false;
316
333
  }
334
+ /**
335
+ * Get player wallet - prioritize config, fallback to runtime detection
336
+ */
337
+ getWallet() {
338
+ const config = this.client.getConfig();
339
+ return config.player?.wallet || getPlayerWallet();
340
+ }
317
341
  /**
318
342
  * Send a watching heartbeat (1 heartbeat = 1 minute watched)
319
343
  */
@@ -325,7 +349,7 @@ var HeartbeatModule = class {
325
349
  method: "POST",
326
350
  body: JSON.stringify({
327
351
  channelSlug: this.currentChannel,
328
- walletAddress: getPlayerWallet(),
352
+ walletAddress: this.getWallet(),
329
353
  sessionId
330
354
  })
331
355
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thestatic-tv/dcl-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Connect your Decentraland scene to thestatic.tv - full channel lineup, metrics tracking, and interactions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",