@thestatic-tv/dcl-sdk 2.2.10 → 2.3.0-dev.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.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import ReactEcs from '@dcl/sdk/react-ecs';
2
+
1
3
  /**
2
4
  * Player identity data from DCL
3
5
  */
@@ -203,6 +205,111 @@ interface ChatUIConfig {
203
205
  */
204
206
  fontScale?: number;
205
207
  }
208
+ /**
209
+ * Stream channel data from the API
210
+ */
211
+ interface StreamData {
212
+ hasChannel: boolean;
213
+ channelId: string | null;
214
+ channelName?: string;
215
+ isLive: boolean;
216
+ hlsUrl: string | null;
217
+ rtmpUrl?: string | null;
218
+ streamKey?: string | null;
219
+ currentViewers: number;
220
+ sparksBalance: number;
221
+ tier?: string;
222
+ /** True if user can claim the one-time streaming trial */
223
+ trialAvailable?: boolean;
224
+ /** Number of Sparks included in trial (240 = 4 hours) */
225
+ trialSparks?: number;
226
+ }
227
+ /**
228
+ * Video slot configuration
229
+ */
230
+ interface VideoSlot {
231
+ id: string;
232
+ name: string;
233
+ url: string;
234
+ }
235
+ /**
236
+ * Command handler for scene-specific commands
237
+ */
238
+ type CommandHandler = (type: string, payload?: Record<string, unknown>) => void;
239
+ /**
240
+ * Custom scene tab definition for Full/Custom tier
241
+ */
242
+ interface SceneTabDefinition {
243
+ /** Tab label shown in the tab bar */
244
+ label: string;
245
+ /** Unique tab ID */
246
+ id: string;
247
+ /** React-ECS component that renders the tab content */
248
+ render: () => any;
249
+ }
250
+ /**
251
+ * Configuration options for AdminPanelModule
252
+ */
253
+ interface AdminPanelConfig {
254
+ /**
255
+ * Scene ID for API calls
256
+ */
257
+ sceneId: string;
258
+ /**
259
+ * Panel title (shown in header)
260
+ */
261
+ title?: string;
262
+ /**
263
+ * Header background color (default: red)
264
+ */
265
+ headerColor?: {
266
+ r: number;
267
+ g: number;
268
+ b: number;
269
+ a: number;
270
+ };
271
+ /**
272
+ * Show Video tab (default: true for Pro tier)
273
+ */
274
+ showVideoTab?: boolean;
275
+ /**
276
+ * Show Mod tab (default: true for owners)
277
+ */
278
+ showModTab?: boolean;
279
+ /**
280
+ * Custom scene tabs (Full/Custom tier only)
281
+ */
282
+ sceneTabs?: SceneTabDefinition[];
283
+ /**
284
+ * Command handler for scene-specific commands (e.g., elevator, lights)
285
+ * Called when admin triggers a command from the panel
286
+ */
287
+ onCommand?: CommandHandler;
288
+ /**
289
+ * Callback when video URL should be played
290
+ */
291
+ onVideoPlay?: (url: string) => void;
292
+ /**
293
+ * Callback when video playback should stop
294
+ */
295
+ onVideoStop?: () => void;
296
+ /**
297
+ * Callback when video slot is selected
298
+ */
299
+ onVideoSlotPlay?: (slot: string) => void;
300
+ /**
301
+ * Callback for broadcast messages
302
+ */
303
+ onBroadcast?: (text: string) => void;
304
+ /**
305
+ * Link shown in footer (default: scene page on thestatic.tv)
306
+ */
307
+ footerLink?: string;
308
+ /**
309
+ * Enable debug logging
310
+ */
311
+ debug?: boolean;
312
+ }
206
313
 
207
314
  /**
208
315
  * Guide module - fetch channel lineup from thestatic.tv
@@ -534,12 +641,106 @@ declare class ChatUIModule {
534
641
  private renderToggleButton;
535
642
  }
536
643
 
644
+ /**
645
+ * Admin Panel UI Module for The Static TV SDK (Pro Tier)
646
+ *
647
+ * Provides in-scene admin controls:
648
+ * - Video Tab: Stream control, video playback, slots
649
+ * - Mod Tab: Scene admins, banned wallets, broadcast
650
+ * - Custom Scene Tabs: Full/Custom tier
651
+ */
652
+
653
+ declare class AdminPanelUIModule {
654
+ private client;
655
+ private config;
656
+ private baseUrl;
657
+ private isAdmin;
658
+ private isOwner;
659
+ private panelOpen;
660
+ private activeTab;
661
+ private playerWallet;
662
+ private customVideoUrl;
663
+ private streamData;
664
+ private streamFetched;
665
+ private channelCreating;
666
+ private channelCreateError;
667
+ private channelDeleting;
668
+ private channelDeleteError;
669
+ private keyRotating;
670
+ private keyRotateStatus;
671
+ private streamControlling;
672
+ private streamControlStatus;
673
+ private pollIntervalId;
674
+ private trialClaiming;
675
+ private trialClaimError;
676
+ private sceneAdmins;
677
+ private bannedWallets;
678
+ private newAdminWallet;
679
+ private newBanWallet;
680
+ private broadcastText;
681
+ private modStatus;
682
+ private modsFetched;
683
+ constructor(client: StaticTVClient, config: AdminPanelConfig);
684
+ private log;
685
+ /**
686
+ * Initialize the admin panel - checks admin status
687
+ */
688
+ init(): Promise<void>;
689
+ /**
690
+ * Check if current player is an admin for this scene
691
+ */
692
+ checkAdminStatus(): Promise<void>;
693
+ /**
694
+ * Toggle the admin panel open/closed
695
+ */
696
+ toggle(): void;
697
+ /**
698
+ * Check if the panel is currently open
699
+ */
700
+ get isOpen(): boolean;
701
+ /**
702
+ * Check if current user has admin access
703
+ */
704
+ get hasAccess(): boolean;
705
+ /**
706
+ * Register a custom scene tab (Full/Custom tier)
707
+ */
708
+ registerSceneTab(tab: SceneTabDefinition): void;
709
+ private startStreamPolling;
710
+ private stopStreamPolling;
711
+ private fetchStreamData;
712
+ private refreshStreamStatus;
713
+ private createChannel;
714
+ private claimTrial;
715
+ private deleteChannel;
716
+ private startStream;
717
+ private stopStream;
718
+ private rotateStreamKey;
719
+ private fetchModData;
720
+ private addSceneAdmin;
721
+ private removeSceneAdmin;
722
+ private banWallet;
723
+ private unbanWallet;
724
+ private banKickPlayer;
725
+ private sendBroadcast;
726
+ private setActiveTab;
727
+ private SectionHead;
728
+ private TabBtn;
729
+ private VideoTab;
730
+ private ModTab;
731
+ /**
732
+ * Get the React-ECS component for the admin panel
733
+ */
734
+ getComponent: () => ReactEcs.JSX.Element | null;
735
+ }
736
+
537
737
  /**
538
738
  * StaticTVClient - Main client for connecting DCL scenes to thestatic.tv
539
739
  *
540
740
  * All keys use dcls_ prefix. Features enabled based on sdkType from server:
541
741
  * - lite: Session tracking only
542
742
  * - full: Guide, Chat, Heartbeat, Interactions + session tracking
743
+ * - pro: Full + Admin Panel (Video + Mod tabs)
543
744
  */
544
745
 
545
746
  /** Key type constants (legacy - kept for compatibility) */
@@ -551,6 +752,7 @@ declare class StaticTVClient {
551
752
  private _keyType;
552
753
  private _disabled;
553
754
  private _fullFeaturesEnabled;
755
+ private _proFeaturesEnabled;
554
756
  /** Guide module - fetch channel lineup (full SDK only) */
555
757
  guide: GuideModule | null;
556
758
  /** Session module - track visitor sessions (all keys, null when disabled) */
@@ -563,6 +765,8 @@ declare class StaticTVClient {
563
765
  guideUI: GuideUIModule | null;
564
766
  /** Chat UI module - real-time chat UI (full SDK only) */
565
767
  chatUI: ChatUIModule | null;
768
+ /** Admin Panel module - Video/Mod tabs (pro SDK only) */
769
+ adminPanel: AdminPanelUIModule | null;
566
770
  /**
567
771
  * Create a new StaticTVClient
568
772
  *
@@ -570,16 +774,15 @@ declare class StaticTVClient {
570
774
  *
571
775
  * @example
572
776
  * ```typescript
573
- * // Full access with channel key
574
- * const staticTV = new StaticTVClient({
575
- * apiKey: 'dclk_your_channel_key_here',
576
- * debug: true
577
- * });
777
+ * let staticTV: StaticTVClient
578
778
  *
579
- * // Lite mode with scene key (visitors only)
580
- * const staticTV = new StaticTVClient({
581
- * apiKey: 'dcls_your_scene_key_here'
582
- * });
779
+ * export function main() {
780
+ * // All keys use dcls_ prefix - features determined by subscription
781
+ * staticTV = new StaticTVClient({
782
+ * apiKey: 'dcls_your_key_here'
783
+ * })
784
+ * // Session tracking starts automatically!
785
+ * }
583
786
  * ```
584
787
  */
585
788
  constructor(config: StaticTVConfig);
@@ -626,10 +829,51 @@ declare class StaticTVClient {
626
829
  * Check if full features are enabled (server confirmed sdkType: 'full')
627
830
  */
628
831
  get hasFullFeatures(): boolean;
832
+ /**
833
+ * Check if pro features are enabled (admin panel)
834
+ */
835
+ get hasProFeatures(): boolean;
629
836
  /**
630
837
  * Get the SDK type (lite or full) - only available after session starts
631
838
  */
632
839
  get sdkType(): 'lite' | 'full';
840
+ /**
841
+ * Enable Pro features (Admin Panel with Video + Mod tabs)
842
+ * Call this after creating the client to add admin panel functionality.
843
+ *
844
+ * @param config Admin panel configuration
845
+ *
846
+ * @example
847
+ * ```typescript
848
+ * const staticTV = new StaticTVClient({ apiKey: 'dcls_...' })
849
+ *
850
+ * // Enable admin panel
851
+ * staticTV.enableProFeatures({
852
+ * sceneId: 'my-scene',
853
+ * title: 'MY SCENE ADMIN',
854
+ * onVideoPlay: (url) => videoPlayer.play(url),
855
+ * onVideoStop: () => videoPlayer.stop(),
856
+ * onBroadcast: (text) => showNotification(text)
857
+ * })
858
+ * ```
859
+ */
860
+ enableProFeatures(config: AdminPanelConfig): void;
861
+ /**
862
+ * Register a custom scene tab for the admin panel (Full/Custom tier)
863
+ * Must call enableProFeatures() first.
864
+ *
865
+ * @param tab The tab definition with label, id, and render function
866
+ *
867
+ * @example
868
+ * ```typescript
869
+ * staticTV.registerSceneTab({
870
+ * label: 'LIGHTS',
871
+ * id: 'lights',
872
+ * render: () => <MyLightsControls />
873
+ * })
874
+ * ```
875
+ */
876
+ registerSceneTab(tab: SceneTabDefinition): void;
633
877
  /**
634
878
  * Cleanup when done (call before scene unload)
635
879
  */
@@ -660,4 +904,4 @@ declare function getPlayerWallet(): string | null;
660
904
  */
661
905
  declare function getPlayerDisplayName(): string | null;
662
906
 
663
- 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 };
907
+ export { type AdminPanelConfig, AdminPanelUIModule, type Channel, type ChatChannel, type ChatMessage, type ChatUIConfig, ChatUIModule, type CommandHandler, 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, type SceneTabDefinition, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type StreamData, type VideoSlot, type Vod, fetchUserData, getPlayerDisplayName, getPlayerWallet };