@thestatic-tv/dcl-sdk 2.0.2 → 2.1.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
@@ -91,6 +91,8 @@ interface GuideResponse {
91
91
  interface SessionResponse {
92
92
  success: boolean;
93
93
  sessionId?: string;
94
+ keyType?: 'scene' | 'channel';
95
+ sdkType?: 'lite' | 'full';
94
96
  version: string;
95
97
  }
96
98
  /**
@@ -247,9 +249,16 @@ declare class SessionModule {
247
249
  private sessionId;
248
250
  private heartbeatTimerId;
249
251
  private isActive;
252
+ private _sdkType;
250
253
  constructor(client: StaticTVClient);
254
+ /**
255
+ * Get the SDK type returned by the server
256
+ * Determines what features are available (lite = sessions only, full = guide + chat + more)
257
+ */
258
+ get sdkType(): 'lite' | 'full';
251
259
  /**
252
260
  * Get the appropriate session endpoint based on key type
261
+ * All dcls_ keys use /scene-session, dclk_ keys use /session
253
262
  */
254
263
  private getEndpoint;
255
264
  /**
@@ -524,12 +533,12 @@ declare class ChatUIModule {
524
533
  /**
525
534
  * StaticTVClient - Main client for connecting DCL scenes to thestatic.tv
526
535
  *
527
- * Supports two key types:
528
- * - dclk_* : Channel keys (full access - guide, heartbeat, interactions, UI)
529
- * - dcls_* : Scene-only keys (lite - session tracking only)
536
+ * All keys use dcls_ prefix. Features enabled based on sdkType from server:
537
+ * - lite: Session tracking only
538
+ * - full: Guide, Chat, Heartbeat, Interactions + session tracking
530
539
  */
531
540
 
532
- /** Key type constants */
541
+ /** Key type constants (legacy - kept for compatibility) */
533
542
  declare const KEY_TYPE_CHANNEL = "channel";
534
543
  declare const KEY_TYPE_SCENE = "scene";
535
544
  declare class StaticTVClient {
@@ -537,18 +546,19 @@ declare class StaticTVClient {
537
546
  private baseUrl;
538
547
  private _keyType;
539
548
  private _disabled;
540
- /** Guide module - fetch channel lineup (channel keys only) */
541
- readonly guide: GuideModule | null;
549
+ private _fullFeaturesEnabled;
550
+ /** Guide module - fetch channel lineup (full SDK only) */
551
+ guide: GuideModule | null;
542
552
  /** Session module - track visitor sessions (all keys, null when disabled) */
543
- readonly session: SessionModule | null;
544
- /** Heartbeat module - track video watching (channel keys only) */
545
- readonly heartbeat: HeartbeatModule | null;
546
- /** Interactions module - like/follow channels (channel keys only) */
547
- readonly interactions: InteractionsModule | null;
548
- /** Guide UI module - channel browser UI (channel keys only) */
549
- readonly guideUI: GuideUIModule | null;
550
- /** Chat UI module - real-time chat UI (channel keys only) */
551
- readonly chatUI: ChatUIModule | null;
553
+ session: SessionModule | null;
554
+ /** Heartbeat module - track video watching (full SDK only) */
555
+ heartbeat: HeartbeatModule | null;
556
+ /** Interactions module - like/follow channels (full SDK only) */
557
+ interactions: InteractionsModule | null;
558
+ /** Guide UI module - channel browser UI (full SDK only) */
559
+ guideUI: GuideUIModule | null;
560
+ /** Chat UI module - real-time chat UI (full SDK only) */
561
+ chatUI: ChatUIModule | null;
552
562
  /**
553
563
  * Create a new StaticTVClient
554
564
  *
@@ -578,7 +588,8 @@ declare class StaticTVClient {
578
588
  */
579
589
  get isDisabled(): boolean;
580
590
  /**
581
- * Check if this is a lite (scene-only) client
591
+ * Check if this is a lite client (no full features)
592
+ * Returns true until session confirms sdkType is 'full'
582
593
  */
583
594
  get isLite(): boolean;
584
595
  /**
@@ -596,6 +607,25 @@ declare class StaticTVClient {
596
607
  * @internal
597
608
  */
598
609
  getConfig(): StaticTVConfig;
610
+ /**
611
+ * Initialize full feature modules (guide, heartbeat, interactions, UI)
612
+ * @internal
613
+ */
614
+ private _initFullModules;
615
+ /**
616
+ * Called by SessionModule when server confirms sdkType is 'full'
617
+ * Enables guide, chat, heartbeat, and interactions modules
618
+ * @internal
619
+ */
620
+ _enableFullFeatures(): void;
621
+ /**
622
+ * Check if full features are enabled (server confirmed sdkType: 'full')
623
+ */
624
+ get hasFullFeatures(): boolean;
625
+ /**
626
+ * Get the SDK type (lite or full) - only available after session starts
627
+ */
628
+ get sdkType(): 'lite' | 'full';
599
629
  /**
600
630
  * Cleanup when done (call before scene unload)
601
631
  */
package/dist/index.d.ts CHANGED
@@ -91,6 +91,8 @@ interface GuideResponse {
91
91
  interface SessionResponse {
92
92
  success: boolean;
93
93
  sessionId?: string;
94
+ keyType?: 'scene' | 'channel';
95
+ sdkType?: 'lite' | 'full';
94
96
  version: string;
95
97
  }
96
98
  /**
@@ -247,9 +249,16 @@ declare class SessionModule {
247
249
  private sessionId;
248
250
  private heartbeatTimerId;
249
251
  private isActive;
252
+ private _sdkType;
250
253
  constructor(client: StaticTVClient);
254
+ /**
255
+ * Get the SDK type returned by the server
256
+ * Determines what features are available (lite = sessions only, full = guide + chat + more)
257
+ */
258
+ get sdkType(): 'lite' | 'full';
251
259
  /**
252
260
  * Get the appropriate session endpoint based on key type
261
+ * All dcls_ keys use /scene-session, dclk_ keys use /session
253
262
  */
254
263
  private getEndpoint;
255
264
  /**
@@ -524,12 +533,12 @@ declare class ChatUIModule {
524
533
  /**
525
534
  * StaticTVClient - Main client for connecting DCL scenes to thestatic.tv
526
535
  *
527
- * Supports two key types:
528
- * - dclk_* : Channel keys (full access - guide, heartbeat, interactions, UI)
529
- * - dcls_* : Scene-only keys (lite - session tracking only)
536
+ * All keys use dcls_ prefix. Features enabled based on sdkType from server:
537
+ * - lite: Session tracking only
538
+ * - full: Guide, Chat, Heartbeat, Interactions + session tracking
530
539
  */
531
540
 
532
- /** Key type constants */
541
+ /** Key type constants (legacy - kept for compatibility) */
533
542
  declare const KEY_TYPE_CHANNEL = "channel";
534
543
  declare const KEY_TYPE_SCENE = "scene";
535
544
  declare class StaticTVClient {
@@ -537,18 +546,19 @@ declare class StaticTVClient {
537
546
  private baseUrl;
538
547
  private _keyType;
539
548
  private _disabled;
540
- /** Guide module - fetch channel lineup (channel keys only) */
541
- readonly guide: GuideModule | null;
549
+ private _fullFeaturesEnabled;
550
+ /** Guide module - fetch channel lineup (full SDK only) */
551
+ guide: GuideModule | null;
542
552
  /** Session module - track visitor sessions (all keys, null when disabled) */
543
- readonly session: SessionModule | null;
544
- /** Heartbeat module - track video watching (channel keys only) */
545
- readonly heartbeat: HeartbeatModule | null;
546
- /** Interactions module - like/follow channels (channel keys only) */
547
- readonly interactions: InteractionsModule | null;
548
- /** Guide UI module - channel browser UI (channel keys only) */
549
- readonly guideUI: GuideUIModule | null;
550
- /** Chat UI module - real-time chat UI (channel keys only) */
551
- readonly chatUI: ChatUIModule | null;
553
+ session: SessionModule | null;
554
+ /** Heartbeat module - track video watching (full SDK only) */
555
+ heartbeat: HeartbeatModule | null;
556
+ /** Interactions module - like/follow channels (full SDK only) */
557
+ interactions: InteractionsModule | null;
558
+ /** Guide UI module - channel browser UI (full SDK only) */
559
+ guideUI: GuideUIModule | null;
560
+ /** Chat UI module - real-time chat UI (full SDK only) */
561
+ chatUI: ChatUIModule | null;
552
562
  /**
553
563
  * Create a new StaticTVClient
554
564
  *
@@ -578,7 +588,8 @@ declare class StaticTVClient {
578
588
  */
579
589
  get isDisabled(): boolean;
580
590
  /**
581
- * Check if this is a lite (scene-only) client
591
+ * Check if this is a lite client (no full features)
592
+ * Returns true until session confirms sdkType is 'full'
582
593
  */
583
594
  get isLite(): boolean;
584
595
  /**
@@ -596,6 +607,25 @@ declare class StaticTVClient {
596
607
  * @internal
597
608
  */
598
609
  getConfig(): StaticTVConfig;
610
+ /**
611
+ * Initialize full feature modules (guide, heartbeat, interactions, UI)
612
+ * @internal
613
+ */
614
+ private _initFullModules;
615
+ /**
616
+ * Called by SessionModule when server confirms sdkType is 'full'
617
+ * Enables guide, chat, heartbeat, and interactions modules
618
+ * @internal
619
+ */
620
+ _enableFullFeatures(): void;
621
+ /**
622
+ * Check if full features are enabled (server confirmed sdkType: 'full')
623
+ */
624
+ get hasFullFeatures(): boolean;
625
+ /**
626
+ * Get the SDK type (lite or full) - only available after session starts
627
+ */
628
+ get sdkType(): 'lite' | 'full';
599
629
  /**
600
630
  * Cleanup when done (call before scene unload)
601
631
  */
package/dist/index.js CHANGED
@@ -249,13 +249,22 @@ var SessionModule = class {
249
249
  this.sessionId = null;
250
250
  this.heartbeatTimerId = null;
251
251
  this.isActive = false;
252
+ this._sdkType = "lite";
252
253
  this.client = client;
253
254
  }
255
+ /**
256
+ * Get the SDK type returned by the server
257
+ * Determines what features are available (lite = sessions only, full = guide + chat + more)
258
+ */
259
+ get sdkType() {
260
+ return this._sdkType;
261
+ }
254
262
  /**
255
263
  * Get the appropriate session endpoint based on key type
264
+ * All dcls_ keys use /scene-session, dclk_ keys use /session
256
265
  */
257
266
  getEndpoint() {
258
- return this.client.isLite ? "/scene-session" : "/session";
267
+ return this.client.keyType === "scene" ? "/scene-session" : "/session";
259
268
  }
260
269
  /**
261
270
  * Get player wallet - prioritize config, fallback to runtime detection
@@ -296,8 +305,12 @@ var SessionModule = class {
296
305
  if (response.success && response.sessionId) {
297
306
  this.sessionId = response.sessionId;
298
307
  this.isActive = true;
308
+ this._sdkType = response.sdkType || "lite";
299
309
  this.startHeartbeat();
300
- this.client.log(`Session started: ${this.sessionId}`);
310
+ this.client.log(`Session started: ${this.sessionId}, sdkType: ${this._sdkType}`);
311
+ if (this._sdkType === "full") {
312
+ this.client._enableFullFeatures();
313
+ }
301
314
  return this.sessionId;
302
315
  }
303
316
  return null;
@@ -2123,6 +2136,19 @@ var StaticTVClient = class {
2123
2136
  constructor(config) {
2124
2137
  this._keyType = null;
2125
2138
  this._disabled = false;
2139
+ this._fullFeaturesEnabled = false;
2140
+ /** Guide module - fetch channel lineup (full SDK only) */
2141
+ this.guide = null;
2142
+ /** Session module - track visitor sessions (all keys, null when disabled) */
2143
+ this.session = null;
2144
+ /** Heartbeat module - track video watching (full SDK only) */
2145
+ this.heartbeat = null;
2146
+ /** Interactions module - like/follow channels (full SDK only) */
2147
+ this.interactions = null;
2148
+ /** Guide UI module - channel browser UI (full SDK only) */
2149
+ this.guideUI = null;
2150
+ /** Chat UI module - real-time chat UI (full SDK only) */
2151
+ this.chatUI = null;
2126
2152
  this.config = {
2127
2153
  autoStartSession: true,
2128
2154
  sessionHeartbeatInterval: 3e4,
@@ -2132,7 +2158,7 @@ var StaticTVClient = class {
2132
2158
  };
2133
2159
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
2134
2160
  if (!config.apiKey) {
2135
- console.warn("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
2161
+ console.log("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
2136
2162
  this._disabled = true;
2137
2163
  this._keyType = null;
2138
2164
  this.session = null;
@@ -2148,30 +2174,14 @@ var StaticTVClient = class {
2148
2174
  } else if (config.apiKey.startsWith("dcls_")) {
2149
2175
  this._keyType = KEY_TYPE_SCENE;
2150
2176
  } else {
2151
- console.warn("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
2177
+ console.log("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
2152
2178
  this._disabled = true;
2153
2179
  this._keyType = null;
2154
- this.session = null;
2155
- this.guide = null;
2156
- this.heartbeat = null;
2157
- this.interactions = null;
2158
- this.guideUI = null;
2159
- this.chatUI = null;
2160
2180
  return;
2161
2181
  }
2162
2182
  this.session = new SessionModule(this);
2163
2183
  if (this._keyType === KEY_TYPE_CHANNEL) {
2164
- this.guide = new GuideModule(this);
2165
- this.heartbeat = new HeartbeatModule(this);
2166
- this.interactions = new InteractionsModule(this);
2167
- this.guideUI = new GuideUIModule(this, config.guideUI);
2168
- this.chatUI = new ChatUIModule(this, config.chatUI);
2169
- } else {
2170
- this.guide = null;
2171
- this.heartbeat = null;
2172
- this.interactions = null;
2173
- this.guideUI = null;
2174
- this.chatUI = null;
2184
+ this._initFullModules();
2175
2185
  }
2176
2186
  if (this.config.autoStartSession) {
2177
2187
  fetchUserData().then(() => {
@@ -2200,10 +2210,11 @@ var StaticTVClient = class {
2200
2210
  return this._disabled;
2201
2211
  }
2202
2212
  /**
2203
- * Check if this is a lite (scene-only) client
2213
+ * Check if this is a lite client (no full features)
2214
+ * Returns true until session confirms sdkType is 'full'
2204
2215
  */
2205
2216
  get isLite() {
2206
- return this._keyType === KEY_TYPE_SCENE;
2217
+ return !this._fullFeaturesEnabled;
2207
2218
  }
2208
2219
  /**
2209
2220
  * Make an authenticated API request
@@ -2236,6 +2247,40 @@ var StaticTVClient = class {
2236
2247
  getConfig() {
2237
2248
  return this.config;
2238
2249
  }
2250
+ /**
2251
+ * Initialize full feature modules (guide, heartbeat, interactions, UI)
2252
+ * @internal
2253
+ */
2254
+ _initFullModules() {
2255
+ if (this._fullFeaturesEnabled) return;
2256
+ this.guide = new GuideModule(this);
2257
+ this.heartbeat = new HeartbeatModule(this);
2258
+ this.interactions = new InteractionsModule(this);
2259
+ this.guideUI = new GuideUIModule(this, this.config.guideUI);
2260
+ this.chatUI = new ChatUIModule(this, this.config.chatUI);
2261
+ this._fullFeaturesEnabled = true;
2262
+ this.log("Full features enabled (guide, chat, heartbeat, interactions)");
2263
+ }
2264
+ /**
2265
+ * Called by SessionModule when server confirms sdkType is 'full'
2266
+ * Enables guide, chat, heartbeat, and interactions modules
2267
+ * @internal
2268
+ */
2269
+ _enableFullFeatures() {
2270
+ this._initFullModules();
2271
+ }
2272
+ /**
2273
+ * Check if full features are enabled (server confirmed sdkType: 'full')
2274
+ */
2275
+ get hasFullFeatures() {
2276
+ return this._fullFeaturesEnabled;
2277
+ }
2278
+ /**
2279
+ * Get the SDK type (lite or full) - only available after session starts
2280
+ */
2281
+ get sdkType() {
2282
+ return this.session?.sdkType || "lite";
2283
+ }
2239
2284
  /**
2240
2285
  * Cleanup when done (call before scene unload)
2241
2286
  */
package/dist/index.mjs CHANGED
@@ -209,13 +209,22 @@ var SessionModule = class {
209
209
  this.sessionId = null;
210
210
  this.heartbeatTimerId = null;
211
211
  this.isActive = false;
212
+ this._sdkType = "lite";
212
213
  this.client = client;
213
214
  }
215
+ /**
216
+ * Get the SDK type returned by the server
217
+ * Determines what features are available (lite = sessions only, full = guide + chat + more)
218
+ */
219
+ get sdkType() {
220
+ return this._sdkType;
221
+ }
214
222
  /**
215
223
  * Get the appropriate session endpoint based on key type
224
+ * All dcls_ keys use /scene-session, dclk_ keys use /session
216
225
  */
217
226
  getEndpoint() {
218
- return this.client.isLite ? "/scene-session" : "/session";
227
+ return this.client.keyType === "scene" ? "/scene-session" : "/session";
219
228
  }
220
229
  /**
221
230
  * Get player wallet - prioritize config, fallback to runtime detection
@@ -256,8 +265,12 @@ var SessionModule = class {
256
265
  if (response.success && response.sessionId) {
257
266
  this.sessionId = response.sessionId;
258
267
  this.isActive = true;
268
+ this._sdkType = response.sdkType || "lite";
259
269
  this.startHeartbeat();
260
- this.client.log(`Session started: ${this.sessionId}`);
270
+ this.client.log(`Session started: ${this.sessionId}, sdkType: ${this._sdkType}`);
271
+ if (this._sdkType === "full") {
272
+ this.client._enableFullFeatures();
273
+ }
261
274
  return this.sessionId;
262
275
  }
263
276
  return null;
@@ -2083,6 +2096,19 @@ var StaticTVClient = class {
2083
2096
  constructor(config) {
2084
2097
  this._keyType = null;
2085
2098
  this._disabled = false;
2099
+ this._fullFeaturesEnabled = false;
2100
+ /** Guide module - fetch channel lineup (full SDK only) */
2101
+ this.guide = null;
2102
+ /** Session module - track visitor sessions (all keys, null when disabled) */
2103
+ this.session = null;
2104
+ /** Heartbeat module - track video watching (full SDK only) */
2105
+ this.heartbeat = null;
2106
+ /** Interactions module - like/follow channels (full SDK only) */
2107
+ this.interactions = null;
2108
+ /** Guide UI module - channel browser UI (full SDK only) */
2109
+ this.guideUI = null;
2110
+ /** Chat UI module - real-time chat UI (full SDK only) */
2111
+ this.chatUI = null;
2086
2112
  this.config = {
2087
2113
  autoStartSession: true,
2088
2114
  sessionHeartbeatInterval: 3e4,
@@ -2092,7 +2118,7 @@ var StaticTVClient = class {
2092
2118
  };
2093
2119
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
2094
2120
  if (!config.apiKey) {
2095
- console.warn("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
2121
+ console.log("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
2096
2122
  this._disabled = true;
2097
2123
  this._keyType = null;
2098
2124
  this.session = null;
@@ -2108,30 +2134,14 @@ var StaticTVClient = class {
2108
2134
  } else if (config.apiKey.startsWith("dcls_")) {
2109
2135
  this._keyType = KEY_TYPE_SCENE;
2110
2136
  } else {
2111
- console.warn("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
2137
+ console.log("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
2112
2138
  this._disabled = true;
2113
2139
  this._keyType = null;
2114
- this.session = null;
2115
- this.guide = null;
2116
- this.heartbeat = null;
2117
- this.interactions = null;
2118
- this.guideUI = null;
2119
- this.chatUI = null;
2120
2140
  return;
2121
2141
  }
2122
2142
  this.session = new SessionModule(this);
2123
2143
  if (this._keyType === KEY_TYPE_CHANNEL) {
2124
- this.guide = new GuideModule(this);
2125
- this.heartbeat = new HeartbeatModule(this);
2126
- this.interactions = new InteractionsModule(this);
2127
- this.guideUI = new GuideUIModule(this, config.guideUI);
2128
- this.chatUI = new ChatUIModule(this, config.chatUI);
2129
- } else {
2130
- this.guide = null;
2131
- this.heartbeat = null;
2132
- this.interactions = null;
2133
- this.guideUI = null;
2134
- this.chatUI = null;
2144
+ this._initFullModules();
2135
2145
  }
2136
2146
  if (this.config.autoStartSession) {
2137
2147
  fetchUserData().then(() => {
@@ -2160,10 +2170,11 @@ var StaticTVClient = class {
2160
2170
  return this._disabled;
2161
2171
  }
2162
2172
  /**
2163
- * Check if this is a lite (scene-only) client
2173
+ * Check if this is a lite client (no full features)
2174
+ * Returns true until session confirms sdkType is 'full'
2164
2175
  */
2165
2176
  get isLite() {
2166
- return this._keyType === KEY_TYPE_SCENE;
2177
+ return !this._fullFeaturesEnabled;
2167
2178
  }
2168
2179
  /**
2169
2180
  * Make an authenticated API request
@@ -2196,6 +2207,40 @@ var StaticTVClient = class {
2196
2207
  getConfig() {
2197
2208
  return this.config;
2198
2209
  }
2210
+ /**
2211
+ * Initialize full feature modules (guide, heartbeat, interactions, UI)
2212
+ * @internal
2213
+ */
2214
+ _initFullModules() {
2215
+ if (this._fullFeaturesEnabled) return;
2216
+ this.guide = new GuideModule(this);
2217
+ this.heartbeat = new HeartbeatModule(this);
2218
+ this.interactions = new InteractionsModule(this);
2219
+ this.guideUI = new GuideUIModule(this, this.config.guideUI);
2220
+ this.chatUI = new ChatUIModule(this, this.config.chatUI);
2221
+ this._fullFeaturesEnabled = true;
2222
+ this.log("Full features enabled (guide, chat, heartbeat, interactions)");
2223
+ }
2224
+ /**
2225
+ * Called by SessionModule when server confirms sdkType is 'full'
2226
+ * Enables guide, chat, heartbeat, and interactions modules
2227
+ * @internal
2228
+ */
2229
+ _enableFullFeatures() {
2230
+ this._initFullModules();
2231
+ }
2232
+ /**
2233
+ * Check if full features are enabled (server confirmed sdkType: 'full')
2234
+ */
2235
+ get hasFullFeatures() {
2236
+ return this._fullFeaturesEnabled;
2237
+ }
2238
+ /**
2239
+ * Get the SDK type (lite or full) - only available after session starts
2240
+ */
2241
+ get sdkType() {
2242
+ return this.session?.sdkType || "lite";
2243
+ }
2199
2244
  /**
2200
2245
  * Cleanup when done (call before scene unload)
2201
2246
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thestatic-tv/dcl-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
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",