@thestatic-tv/dcl-sdk 1.0.7 → 2.0.0-beta.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/README.md CHANGED
@@ -1,51 +1,55 @@
1
- # @thestatic/dcl-sdk
1
+ # @thestatic-tv/dcl-sdk
2
2
 
3
3
  Connect your Decentraland scene to [thestatic.tv](https://thestatic.tv) - the decentralized streaming platform.
4
4
 
5
+ [![npm version](https://img.shields.io/npm/v/@thestatic-tv/dcl-sdk?color=00e5e5)](https://www.npmjs.com/package/@thestatic-tv/dcl-sdk)
6
+ [![DCL SDK](https://img.shields.io/badge/DCL%20SDK-7.x-blue)](https://docs.decentraland.org/)
7
+
5
8
  This SDK allows DCL scene builders to:
9
+ - Track visitors to your Decentraland scene
6
10
  - Display the full thestatic.tv channel lineup in their scenes
7
11
  - Track video watching metrics
8
12
  - Enable likes/follows from within DCL
9
13
  - Get referral credit for driving traffic to channels
10
14
 
11
- ## Two Modes
15
+ ## Pricing
12
16
 
13
- | Mode | Key Prefix | Features | Get Key From |
14
- |------|------------|----------|--------------|
15
- | **Full** | `dclk_` | Guide, Heartbeat, Sessions, Interactions | Studio (channel owners) |
16
- | **Lite** | `dcls_` | Sessions only (visitor tracking) | Profile (all users) |
17
+ | Mode | Price | Key Prefix | Features |
18
+ |------|-------|------------|----------|
19
+ | **Lite** | $5/mo | `dcls_` | Session/visitor tracking only |
20
+ | **Full** | $10/mo | `dclk_` | Guide, Heartbeat, Sessions, Interactions, **Guide UI**, **Chat UI** |
17
21
 
18
- The SDK auto-detects your key type and enables/disables features accordingly.
22
+ > **Free Trial**: All new scene keys include a 7-day free trial!
19
23
 
20
- > **Free Trial**: New accounts get 7 days of free visitor tracking!
24
+ Get your key from [thestatic.tv/dashboard](https://thestatic.tv/dashboard) DCL Scenes tab.
21
25
 
22
26
  ## Example Scene
23
27
 
24
- Clone our example scene to get started quickly:
28
+ Clone our starter scene to get started quickly:
25
29
 
26
30
  ```bash
27
- git clone https://github.com/thestatic-tv/dcl-example.git
28
- cd dcl-example
31
+ git clone https://github.com/thestatic-tv/thestatic-dcl-starter.git
32
+ cd thestatic-dcl-starter
29
33
  npm install
30
34
  npm start
31
35
  ```
32
36
 
33
- See the [example repo](https://github.com/thestatic-tv/dcl-example) for a complete working scene.
37
+ See the [starter repo](https://github.com/thestatic-tv/thestatic-dcl-starter) for a complete working scene.
34
38
 
35
39
  ## Installation
36
40
 
37
41
  ```bash
38
- npm install @thestatic/dcl-sdk
42
+ npm install @thestatic-tv/dcl-sdk
39
43
  ```
40
44
 
41
45
  ## Quick Start
42
46
 
43
- 1. Get your API key from [thestatic.tv/studio](https://thestatic.tv/studio) (DCL Integration tab)
47
+ 1. Get your API key from [thestatic.tv/dashboard](https://thestatic.tv/dashboard) (DCL Scenes tab)
44
48
 
45
49
  2. Initialize the client in your scene:
46
50
 
47
51
  ```typescript
48
- import { StaticTVClient } from '@thestatic/dcl-sdk'
52
+ import { StaticTVClient } from '@thestatic-tv/dcl-sdk'
49
53
 
50
54
  const staticTV = new StaticTVClient({
51
55
  apiKey: 'dclk_your_api_key_here',
@@ -96,12 +100,12 @@ await staticTV.destroy()
96
100
 
97
101
  If you don't have a channel but want to track visitors to your scene:
98
102
 
99
- 1. Get a scene key from [thestatic.tv/profile](https://thestatic.tv/profile) (DCL Scenes tab)
103
+ 1. Get a scene key from [thestatic.tv/dashboard](https://thestatic.tv/dashboard) (DCL Scenes tab)
100
104
 
101
105
  2. Initialize with your scene key:
102
106
 
103
107
  ```typescript
104
- import { StaticTVClient } from '@thestatic/dcl-sdk'
108
+ import { StaticTVClient } from '@thestatic-tv/dcl-sdk'
105
109
 
106
110
  const staticTV = new StaticTVClient({
107
111
  apiKey: 'dcls_your_scene_key_here'
@@ -150,6 +154,8 @@ Main client class for interacting with thestatic.tv.
150
154
  | `session` | `SessionModule` | Session module (always available) |
151
155
  | `heartbeat` | `HeartbeatModule \| null` | Heartbeat module (null in lite mode) |
152
156
  | `interactions` | `InteractionsModule \| null` | Interactions module (null in lite mode) |
157
+ | `guideUI` | `GuideUIModule \| null` | Guide UI module (null in lite mode) |
158
+ | `chatUI` | `ChatUIModule \| null` | Chat UI module (null in lite mode) |
153
159
 
154
160
  ### Guide Module (Full Mode Only)
155
161
 
@@ -192,6 +198,91 @@ staticTV.interactions.like(channelSlug) // Like a channel
192
198
  staticTV.interactions.follow(channelSlug) // Follow a channel
193
199
  ```
194
200
 
201
+ ### Guide UI Module (Full Mode Only)
202
+
203
+ Built-in channel browser UI. You provide a callback to handle video selection.
204
+
205
+ ```typescript
206
+ // Configure in constructor
207
+ const staticTV = new StaticTVClient({
208
+ apiKey: 'dclk_your_api_key',
209
+ guideUI: {
210
+ onVideoSelect: (video) => {
211
+ // Handle video playback in your scene
212
+ console.log('Playing:', video.name, video.src)
213
+ }
214
+ }
215
+ })
216
+
217
+ // Initialize the UI (call once after client is created)
218
+ await staticTV.guideUI.init()
219
+
220
+ // Show/hide the guide
221
+ staticTV.guideUI.show()
222
+ staticTV.guideUI.hide()
223
+ staticTV.guideUI.toggle()
224
+
225
+ // Check visibility
226
+ if (staticTV.guideUI.isVisible) { ... }
227
+
228
+ // Update "PLAYING" indicator
229
+ staticTV.guideUI.currentVideoId = 'video-id'
230
+
231
+ // Refresh data
232
+ await staticTV.guideUI.refresh()
233
+ ```
234
+
235
+ ### Chat UI Module (Full Mode Only)
236
+
237
+ Real-time chat with Firebase authentication.
238
+
239
+ ```typescript
240
+ // Configure in constructor
241
+ const staticTV = new StaticTVClient({
242
+ apiKey: 'dclk_your_api_key',
243
+ chatUI: {
244
+ position: 'right', // 'left', 'center', or 'right'
245
+ fontScale: 1.0
246
+ }
247
+ })
248
+
249
+ // Initialize the chat (call once after client is created)
250
+ await staticTV.chatUI.init()
251
+
252
+ // Show/hide the chat
253
+ staticTV.chatUI.show()
254
+ staticTV.chatUI.hide()
255
+ staticTV.chatUI.toggle()
256
+
257
+ // Check visibility
258
+ if (staticTV.chatUI.isVisible) { ... }
259
+
260
+ // Get unread message count (for badge display)
261
+ const unread = staticTV.chatUI.unreadCount
262
+
263
+ // Switch channels
264
+ staticTV.chatUI.setChannel('channel-slug')
265
+ ```
266
+
267
+ ### Rendering UI Components
268
+
269
+ The UI modules provide `getComponent()` methods that return React-ECS elements. Call these in your UI renderer:
270
+
271
+ ```typescript
272
+ import { ReactEcsRenderer } from '@dcl/sdk/react-ecs'
273
+
274
+ // In your scene setup
275
+ ReactEcsRenderer.setUiRenderer(() => {
276
+ return (
277
+ <>
278
+ {/* Your other UI elements */}
279
+ {staticTV.guideUI?.getComponent()}
280
+ {staticTV.chatUI?.getComponent()}
281
+ </>
282
+ )
283
+ })
284
+ ```
285
+
195
286
  ## Metrics Attribution
196
287
 
197
288
  This SDK implements dual attribution:
package/dist/index.d.mts CHANGED
@@ -34,6 +34,14 @@ interface StaticTVConfig {
34
34
  * })
35
35
  */
36
36
  player?: PlayerData;
37
+ /**
38
+ * Guide UI configuration (channel keys only)
39
+ */
40
+ guideUI?: GuideUIConfig;
41
+ /**
42
+ * Chat UI configuration (channel keys only)
43
+ */
44
+ chatUI?: ChatUIConfig;
37
45
  }
38
46
  /**
39
47
  * Channel information from the guide
@@ -124,6 +132,75 @@ interface SceneStatsResponse {
124
132
  sceneName: string | null;
125
133
  version: string;
126
134
  }
135
+ /**
136
+ * Video data for the guide UI
137
+ */
138
+ interface GuideVideo {
139
+ id: string;
140
+ name: string;
141
+ src: string;
142
+ isLive?: boolean;
143
+ isCreator?: boolean;
144
+ channelId?: string;
145
+ duration?: number;
146
+ requiresAuth?: boolean;
147
+ }
148
+ /**
149
+ * Featured playlist for the guide UI
150
+ */
151
+ interface GuideFeaturedPlaylist {
152
+ name: string;
153
+ videos: GuideVideo[];
154
+ }
155
+ /**
156
+ * Configuration options for GuideUIModule
157
+ */
158
+ interface GuideUIConfig {
159
+ /**
160
+ * Callback when user selects a video
161
+ * Developer should handle playback
162
+ */
163
+ onVideoSelect?: (video: GuideVideo) => void;
164
+ /**
165
+ * Current video ID (for "PLAYING" indicator)
166
+ */
167
+ currentVideoId?: string;
168
+ /**
169
+ * UI scale multiplier (default: 1.0)
170
+ */
171
+ uiScale?: number;
172
+ }
173
+ /**
174
+ * Chat channel data
175
+ */
176
+ interface ChatChannel {
177
+ id: string;
178
+ name: string;
179
+ }
180
+ /**
181
+ * Chat message data
182
+ */
183
+ interface ChatMessage {
184
+ id: string;
185
+ username: string;
186
+ text: string;
187
+ uid: string;
188
+ createdAt: any;
189
+ isSystem?: boolean;
190
+ }
191
+ /**
192
+ * Configuration options for ChatUIModule
193
+ */
194
+ interface ChatUIConfig {
195
+ /**
196
+ * Chat panel position (default: 'right')
197
+ */
198
+ position?: 'left' | 'center' | 'right';
199
+ /**
200
+ * Font scale multiplier (default: 1.0)
201
+ */
202
+ fontScale?: number;
203
+ }
127
204
 
128
205
  /**
129
206
  * Guide module - fetch channel lineup from thestatic.tv
@@ -279,11 +356,176 @@ declare class InteractionsModule {
279
356
  follow(channelSlug: string): Promise<InteractionResponse | null>;
280
357
  }
281
358
 
359
+ /**
360
+ * Guide UI Module - provides channel/video browser
361
+ */
362
+ declare class GuideUIModule {
363
+ private client;
364
+ private config;
365
+ private _isVisible;
366
+ private videos;
367
+ private featuredPlaylists;
368
+ private liveVideos;
369
+ private activeTab;
370
+ private currentPage;
371
+ private itemsPerPage;
372
+ private searchQuery;
373
+ private uiScale;
374
+ private _currentVideoId;
375
+ constructor(client: StaticTVClient, config?: GuideUIConfig);
376
+ /**
377
+ * Initialize the guide - fetch channel data
378
+ */
379
+ init(): Promise<void>;
380
+ /**
381
+ * Show the guide UI
382
+ */
383
+ show(): void;
384
+ /**
385
+ * Hide the guide UI
386
+ */
387
+ hide(): void;
388
+ /**
389
+ * Toggle guide visibility
390
+ */
391
+ toggle(): void;
392
+ /**
393
+ * Check if guide is visible
394
+ */
395
+ get isVisible(): boolean;
396
+ /**
397
+ * Set the currently playing video ID (for "PLAYING" indicator)
398
+ */
399
+ set currentVideoId(id: string | null);
400
+ /**
401
+ * Get the currently playing video ID
402
+ */
403
+ get currentVideoId(): string | null;
404
+ /**
405
+ * Get all videos
406
+ */
407
+ getVideos(): GuideVideo[];
408
+ /**
409
+ * Get live videos only
410
+ */
411
+ getLiveVideos(): GuideVideo[];
412
+ /**
413
+ * Refresh guide data
414
+ */
415
+ refresh(): Promise<void>;
416
+ private getBaseUrl;
417
+ private fetchGuideData;
418
+ private s;
419
+ private handleVideoSelect;
420
+ private handleChannelClick;
421
+ /**
422
+ * Get the guide UI component for rendering
423
+ */
424
+ getComponent: () => any;
425
+ private renderLeftPanel;
426
+ private renderMenuButton;
427
+ private renderRightPanel;
428
+ private renderCardGrid;
429
+ private renderGuideCard;
430
+ private renderCloseButton;
431
+ }
432
+
433
+ /**
434
+ * Chat UI Module - provides real-time chat functionality
435
+ */
436
+ declare class ChatUIModule {
437
+ private client;
438
+ private config;
439
+ private _isVisible;
440
+ private _unreadCount;
441
+ private idToken;
442
+ private isSigningIn;
443
+ private isRegisteredUser;
444
+ private currentUsername;
445
+ private currentUserId;
446
+ private channels;
447
+ private currentChannelId;
448
+ private showChannelDropdown;
449
+ private channelPage;
450
+ private realMessages;
451
+ private systemMessages;
452
+ private inputText;
453
+ private chatScrollOffset;
454
+ private position;
455
+ private fontScale;
456
+ private chatTimerId;
457
+ private playerInfoTimerId;
458
+ private isInitialized;
459
+ constructor(client: StaticTVClient, config?: ChatUIConfig);
460
+ /**
461
+ * Initialize the chat system
462
+ */
463
+ init(): Promise<void>;
464
+ /**
465
+ * Show the chat UI
466
+ */
467
+ show(): void;
468
+ /**
469
+ * Hide the chat UI
470
+ */
471
+ hide(): void;
472
+ /**
473
+ * Toggle chat visibility
474
+ */
475
+ toggle(): void;
476
+ /**
477
+ * Check if chat is visible
478
+ */
479
+ get isVisible(): boolean;
480
+ /**
481
+ * Get unread message count
482
+ */
483
+ get unreadCount(): number;
484
+ /**
485
+ * Get current channel ID
486
+ */
487
+ get currentChannel(): string;
488
+ /**
489
+ * Switch to a different channel
490
+ */
491
+ setChannel(channelId: string): void;
492
+ /**
493
+ * Cleanup resources
494
+ */
495
+ destroy(): void;
496
+ private getBaseUrl;
497
+ private performAuth;
498
+ private fetchChannels;
499
+ private fetchMessages;
500
+ private handleSend;
501
+ private generateBootSequence;
502
+ private fetchPlayerInfo;
503
+ private switchChannel;
504
+ private startChatLoop;
505
+ private chatLoop;
506
+ private resetChatTimer;
507
+ private parseServerTime;
508
+ private formatTime;
509
+ /**
510
+ * Get the chat UI component for rendering
511
+ */
512
+ getComponent: () => any;
513
+ private getPositionStyle;
514
+ private renderHeader;
515
+ private renderChannelButton;
516
+ private renderMessagesArea;
517
+ private renderSystemMessage;
518
+ private renderChatMessage;
519
+ private renderUserInfoBar;
520
+ private renderInputArea;
521
+ private renderChannelDropdown;
522
+ }
523
+
282
524
  /**
283
525
  * StaticTVClient - Main client for connecting DCL scenes to thestatic.tv
284
526
  *
285
527
  * Supports two key types:
286
- * - dclk_* : Channel keys (full access - guide, heartbeat, interactions)
528
+ * - dclk_* : Channel keys (full access - guide, heartbeat, interactions, UI)
287
529
  * - dcls_* : Scene-only keys (lite - session tracking only)
288
530
  */
289
531
 
@@ -302,6 +544,10 @@ declare class StaticTVClient {
302
544
  readonly heartbeat: HeartbeatModule | null;
303
545
  /** Interactions module - like/follow channels (channel keys only) */
304
546
  readonly interactions: InteractionsModule | null;
547
+ /** Guide UI module - channel browser UI (channel keys only) */
548
+ readonly guideUI: GuideUIModule | null;
549
+ /** Chat UI module - real-time chat UI (channel keys only) */
550
+ readonly chatUI: ChatUIModule | null;
305
551
  /**
306
552
  * Create a new StaticTVClient
307
553
  *
@@ -375,4 +621,4 @@ declare function getPlayerWallet(): string | null;
375
621
  */
376
622
  declare function getPlayerDisplayName(): string | null;
377
623
 
378
- export { type Channel, GuideModule, type GuideResponse, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, type PlayerData, type SceneStats, type SceneStatsResponse, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod, fetchUserData, getPlayerDisplayName, getPlayerWallet };
624
+ export { type Channel, type ChatChannel, type ChatMessage, type ChatUIConfig, ChatUIModule, type GuideFeaturedPlaylist, GuideModule, type GuideResponse, type GuideUIConfig, GuideUIModule, type GuideVideo, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, type PlayerData, type SceneStats, type SceneStatsResponse, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod, fetchUserData, getPlayerDisplayName, getPlayerWallet };