@thestatic-tv/dcl-sdk 2.5.26 → 2.5.29
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 +20 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.js +25 -12
- package/dist/index.mjs +25 -12
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -87,6 +87,7 @@ interface StaticTVConfig {
|
|
|
87
87
|
debug?: boolean;
|
|
88
88
|
/** Custom API base URL (default: https://thestatic.tv/api/v1/dcl) */
|
|
89
89
|
baseUrl?: string;
|
|
90
|
+
apiUrl?: string;
|
|
90
91
|
/**
|
|
91
92
|
* Player data from DCL - pass from your scene's getPlayer() call
|
|
92
93
|
* @example
|
|
@@ -98,6 +99,18 @@ interface StaticTVConfig {
|
|
|
98
99
|
* })
|
|
99
100
|
*/
|
|
100
101
|
player?: PlayerData;
|
|
102
|
+
/**
|
|
103
|
+
* Custom boundary check function — overrides the SDK's auto-detected parcel bounds.
|
|
104
|
+
* Use this for L-shaped or irregular estates where the bounding box is too large.
|
|
105
|
+
* Return true if the player is physically inside your scene, false if nearby but outside.
|
|
106
|
+
* @example
|
|
107
|
+
* customBoundsCheck: () => {
|
|
108
|
+
* const pos = getPlayerPosition()
|
|
109
|
+
* if (!pos) return false
|
|
110
|
+
* return (pos.x >= 0 && pos.x <= 16 && pos.z >= 0 && pos.z <= 64)
|
|
111
|
+
* }
|
|
112
|
+
*/
|
|
113
|
+
customBoundsCheck?: () => boolean;
|
|
101
114
|
/**
|
|
102
115
|
* Guide UI configuration
|
|
103
116
|
*/
|
|
@@ -469,7 +482,8 @@ declare class SessionModule {
|
|
|
469
482
|
*/
|
|
470
483
|
get bounds(): SceneBounds$1 | null;
|
|
471
484
|
/**
|
|
472
|
-
* Check if player is currently within scene bounds
|
|
485
|
+
* Check if player is currently within scene bounds.
|
|
486
|
+
* Uses customBoundsCheck from config if provided, otherwise falls back to auto-detected parcel bounds.
|
|
473
487
|
*/
|
|
474
488
|
isPlayerInScene(): boolean;
|
|
475
489
|
/**
|
|
@@ -916,6 +930,7 @@ declare const KEY_TYPE_SCENE = "scene";
|
|
|
916
930
|
declare class StaticTVClient {
|
|
917
931
|
private config;
|
|
918
932
|
private baseUrl;
|
|
933
|
+
readonly apiUrl: string;
|
|
919
934
|
private _keyType;
|
|
920
935
|
private _keyId;
|
|
921
936
|
private _disabled;
|
|
@@ -1359,10 +1374,11 @@ interface SceneBounds {
|
|
|
1359
1374
|
*/
|
|
1360
1375
|
declare function getSceneBounds(): Promise<SceneBounds | null>;
|
|
1361
1376
|
/**
|
|
1362
|
-
* Check if player is within scene boundaries
|
|
1363
|
-
*
|
|
1377
|
+
* Check if player is within any of the scene's parcel boundaries.
|
|
1378
|
+
* Checks each parcel individually so irregular/L-shaped estates work correctly.
|
|
1379
|
+
* Returns true if in bounds, false if out of bounds or can't determine.
|
|
1364
1380
|
*/
|
|
1365
|
-
declare function isPlayerInBounds(
|
|
1381
|
+
declare function isPlayerInBounds(_bounds: SceneBounds): boolean;
|
|
1366
1382
|
/**
|
|
1367
1383
|
* Get player's current position
|
|
1368
1384
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ interface StaticTVConfig {
|
|
|
87
87
|
debug?: boolean;
|
|
88
88
|
/** Custom API base URL (default: https://thestatic.tv/api/v1/dcl) */
|
|
89
89
|
baseUrl?: string;
|
|
90
|
+
apiUrl?: string;
|
|
90
91
|
/**
|
|
91
92
|
* Player data from DCL - pass from your scene's getPlayer() call
|
|
92
93
|
* @example
|
|
@@ -98,6 +99,18 @@ interface StaticTVConfig {
|
|
|
98
99
|
* })
|
|
99
100
|
*/
|
|
100
101
|
player?: PlayerData;
|
|
102
|
+
/**
|
|
103
|
+
* Custom boundary check function — overrides the SDK's auto-detected parcel bounds.
|
|
104
|
+
* Use this for L-shaped or irregular estates where the bounding box is too large.
|
|
105
|
+
* Return true if the player is physically inside your scene, false if nearby but outside.
|
|
106
|
+
* @example
|
|
107
|
+
* customBoundsCheck: () => {
|
|
108
|
+
* const pos = getPlayerPosition()
|
|
109
|
+
* if (!pos) return false
|
|
110
|
+
* return (pos.x >= 0 && pos.x <= 16 && pos.z >= 0 && pos.z <= 64)
|
|
111
|
+
* }
|
|
112
|
+
*/
|
|
113
|
+
customBoundsCheck?: () => boolean;
|
|
101
114
|
/**
|
|
102
115
|
* Guide UI configuration
|
|
103
116
|
*/
|
|
@@ -469,7 +482,8 @@ declare class SessionModule {
|
|
|
469
482
|
*/
|
|
470
483
|
get bounds(): SceneBounds$1 | null;
|
|
471
484
|
/**
|
|
472
|
-
* Check if player is currently within scene bounds
|
|
485
|
+
* Check if player is currently within scene bounds.
|
|
486
|
+
* Uses customBoundsCheck from config if provided, otherwise falls back to auto-detected parcel bounds.
|
|
473
487
|
*/
|
|
474
488
|
isPlayerInScene(): boolean;
|
|
475
489
|
/**
|
|
@@ -916,6 +930,7 @@ declare const KEY_TYPE_SCENE = "scene";
|
|
|
916
930
|
declare class StaticTVClient {
|
|
917
931
|
private config;
|
|
918
932
|
private baseUrl;
|
|
933
|
+
readonly apiUrl: string;
|
|
919
934
|
private _keyType;
|
|
920
935
|
private _keyId;
|
|
921
936
|
private _disabled;
|
|
@@ -1359,10 +1374,11 @@ interface SceneBounds {
|
|
|
1359
1374
|
*/
|
|
1360
1375
|
declare function getSceneBounds(): Promise<SceneBounds | null>;
|
|
1361
1376
|
/**
|
|
1362
|
-
* Check if player is within scene boundaries
|
|
1363
|
-
*
|
|
1377
|
+
* Check if player is within any of the scene's parcel boundaries.
|
|
1378
|
+
* Checks each parcel individually so irregular/L-shaped estates work correctly.
|
|
1379
|
+
* Returns true if in bounds, false if out of bounds or can't determine.
|
|
1364
1380
|
*/
|
|
1365
|
-
declare function isPlayerInBounds(
|
|
1381
|
+
declare function isPlayerInBounds(_bounds: SceneBounds): boolean;
|
|
1366
1382
|
/**
|
|
1367
1383
|
* Get player's current position
|
|
1368
1384
|
*/
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,7 @@ var import_ecs2 = require("@dcl/sdk/ecs");
|
|
|
256
256
|
var import_Runtime = require("~system/Runtime");
|
|
257
257
|
var PARCEL_SIZE = 16;
|
|
258
258
|
var cachedBounds = null;
|
|
259
|
+
var cachedParcelRects = [];
|
|
259
260
|
var boundsInitialized = false;
|
|
260
261
|
var boundsError = false;
|
|
261
262
|
function parseParcel(parcel) {
|
|
@@ -291,6 +292,16 @@ async function getSceneBounds() {
|
|
|
291
292
|
boundsError = true;
|
|
292
293
|
return null;
|
|
293
294
|
}
|
|
295
|
+
const base = baseParcel ? parseParcel(baseParcel) : coords[0];
|
|
296
|
+
if (!base) {
|
|
297
|
+
boundsError = true;
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
cachedParcelRects = coords.map((c) => {
|
|
301
|
+
const minX = (c.x - base.x) * PARCEL_SIZE;
|
|
302
|
+
const minZ = (c.z - base.z) * PARCEL_SIZE;
|
|
303
|
+
return { minX, maxX: minX + PARCEL_SIZE, minZ, maxZ: minZ + PARCEL_SIZE };
|
|
304
|
+
});
|
|
294
305
|
const worldMinX = Math.min(...coords.map((c) => c.x));
|
|
295
306
|
const worldMaxX = Math.max(...coords.map((c) => c.x));
|
|
296
307
|
const worldMinZ = Math.min(...coords.map((c) => c.z));
|
|
@@ -313,13 +324,15 @@ async function getSceneBounds() {
|
|
|
313
324
|
return null;
|
|
314
325
|
}
|
|
315
326
|
}
|
|
316
|
-
function isPlayerInBounds(
|
|
327
|
+
function isPlayerInBounds(_bounds) {
|
|
317
328
|
try {
|
|
318
329
|
const transform = import_ecs2.Transform.getOrNull(import_ecs2.engine.PlayerEntity);
|
|
319
330
|
if (!transform) return false;
|
|
320
|
-
const
|
|
331
|
+
const { x, z } = transform.position;
|
|
321
332
|
const buffer = 0.5;
|
|
322
|
-
return
|
|
333
|
+
return cachedParcelRects.some(
|
|
334
|
+
(r) => x >= r.minX - buffer && x <= r.maxX + buffer && z >= r.minZ - buffer && z <= r.maxZ + buffer
|
|
335
|
+
);
|
|
323
336
|
} catch {
|
|
324
337
|
return false;
|
|
325
338
|
}
|
|
@@ -366,9 +379,12 @@ var SessionModule = class {
|
|
|
366
379
|
return this._bounds;
|
|
367
380
|
}
|
|
368
381
|
/**
|
|
369
|
-
* Check if player is currently within scene bounds
|
|
382
|
+
* Check if player is currently within scene bounds.
|
|
383
|
+
* Uses customBoundsCheck from config if provided, otherwise falls back to auto-detected parcel bounds.
|
|
370
384
|
*/
|
|
371
385
|
isPlayerInScene() {
|
|
386
|
+
const customCheck = this.client.getConfig().customBoundsCheck;
|
|
387
|
+
if (customCheck) return customCheck();
|
|
372
388
|
if (!this._bounds) return true;
|
|
373
389
|
return isPlayerInBounds(this._bounds);
|
|
374
390
|
}
|
|
@@ -3957,6 +3973,7 @@ var StaticTVClient = class {
|
|
|
3957
3973
|
...config
|
|
3958
3974
|
};
|
|
3959
3975
|
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
3976
|
+
this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
|
|
3960
3977
|
if (!config.apiKey) {
|
|
3961
3978
|
this._disabled = true;
|
|
3962
3979
|
this._keyType = null;
|
|
@@ -4009,7 +4026,7 @@ var StaticTVClient = class {
|
|
|
4009
4026
|
}
|
|
4010
4027
|
/** Get the API base URL (for internal module use) */
|
|
4011
4028
|
getBaseUrl() {
|
|
4012
|
-
return this.
|
|
4029
|
+
return this.apiUrl;
|
|
4013
4030
|
}
|
|
4014
4031
|
/**
|
|
4015
4032
|
* Get the key type (channel, scene, or null if disabled)
|
|
@@ -4076,7 +4093,7 @@ var StaticTVClient = class {
|
|
|
4076
4093
|
* @internal
|
|
4077
4094
|
*/
|
|
4078
4095
|
async request(endpoint, options = {}) {
|
|
4079
|
-
const url = `${this.
|
|
4096
|
+
const url = `${this.apiUrl}${endpoint}`;
|
|
4080
4097
|
return request(url, {
|
|
4081
4098
|
...options,
|
|
4082
4099
|
headers: {
|
|
@@ -4326,12 +4343,8 @@ var StaticTVClient = class {
|
|
|
4326
4343
|
}
|
|
4327
4344
|
if (hasCallback) {
|
|
4328
4345
|
this.config.onVideoPlay(video.src);
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
} else {
|
|
4332
|
-
this._streamVerified = true;
|
|
4333
|
-
this._pendingVideoData = null;
|
|
4334
|
-
}
|
|
4346
|
+
this._streamVerified = true;
|
|
4347
|
+
this._pendingVideoData = null;
|
|
4335
4348
|
}
|
|
4336
4349
|
if (this.guideUI) {
|
|
4337
4350
|
this.guideUI.currentVideoId = video.id;
|
package/dist/index.mjs
CHANGED
|
@@ -208,6 +208,7 @@ import { engine as engine2, Transform } from "@dcl/sdk/ecs";
|
|
|
208
208
|
import { getSceneInformation } from "~system/Runtime";
|
|
209
209
|
var PARCEL_SIZE = 16;
|
|
210
210
|
var cachedBounds = null;
|
|
211
|
+
var cachedParcelRects = [];
|
|
211
212
|
var boundsInitialized = false;
|
|
212
213
|
var boundsError = false;
|
|
213
214
|
function parseParcel(parcel) {
|
|
@@ -243,6 +244,16 @@ async function getSceneBounds() {
|
|
|
243
244
|
boundsError = true;
|
|
244
245
|
return null;
|
|
245
246
|
}
|
|
247
|
+
const base = baseParcel ? parseParcel(baseParcel) : coords[0];
|
|
248
|
+
if (!base) {
|
|
249
|
+
boundsError = true;
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
cachedParcelRects = coords.map((c) => {
|
|
253
|
+
const minX = (c.x - base.x) * PARCEL_SIZE;
|
|
254
|
+
const minZ = (c.z - base.z) * PARCEL_SIZE;
|
|
255
|
+
return { minX, maxX: minX + PARCEL_SIZE, minZ, maxZ: minZ + PARCEL_SIZE };
|
|
256
|
+
});
|
|
246
257
|
const worldMinX = Math.min(...coords.map((c) => c.x));
|
|
247
258
|
const worldMaxX = Math.max(...coords.map((c) => c.x));
|
|
248
259
|
const worldMinZ = Math.min(...coords.map((c) => c.z));
|
|
@@ -265,13 +276,15 @@ async function getSceneBounds() {
|
|
|
265
276
|
return null;
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
|
-
function isPlayerInBounds(
|
|
279
|
+
function isPlayerInBounds(_bounds) {
|
|
269
280
|
try {
|
|
270
281
|
const transform = Transform.getOrNull(engine2.PlayerEntity);
|
|
271
282
|
if (!transform) return false;
|
|
272
|
-
const
|
|
283
|
+
const { x, z } = transform.position;
|
|
273
284
|
const buffer = 0.5;
|
|
274
|
-
return
|
|
285
|
+
return cachedParcelRects.some(
|
|
286
|
+
(r) => x >= r.minX - buffer && x <= r.maxX + buffer && z >= r.minZ - buffer && z <= r.maxZ + buffer
|
|
287
|
+
);
|
|
275
288
|
} catch {
|
|
276
289
|
return false;
|
|
277
290
|
}
|
|
@@ -318,9 +331,12 @@ var SessionModule = class {
|
|
|
318
331
|
return this._bounds;
|
|
319
332
|
}
|
|
320
333
|
/**
|
|
321
|
-
* Check if player is currently within scene bounds
|
|
334
|
+
* Check if player is currently within scene bounds.
|
|
335
|
+
* Uses customBoundsCheck from config if provided, otherwise falls back to auto-detected parcel bounds.
|
|
322
336
|
*/
|
|
323
337
|
isPlayerInScene() {
|
|
338
|
+
const customCheck = this.client.getConfig().customBoundsCheck;
|
|
339
|
+
if (customCheck) return customCheck();
|
|
324
340
|
if (!this._bounds) return true;
|
|
325
341
|
return isPlayerInBounds(this._bounds);
|
|
326
342
|
}
|
|
@@ -3909,6 +3925,7 @@ var StaticTVClient = class {
|
|
|
3909
3925
|
...config
|
|
3910
3926
|
};
|
|
3911
3927
|
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
3928
|
+
this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
|
|
3912
3929
|
if (!config.apiKey) {
|
|
3913
3930
|
this._disabled = true;
|
|
3914
3931
|
this._keyType = null;
|
|
@@ -3961,7 +3978,7 @@ var StaticTVClient = class {
|
|
|
3961
3978
|
}
|
|
3962
3979
|
/** Get the API base URL (for internal module use) */
|
|
3963
3980
|
getBaseUrl() {
|
|
3964
|
-
return this.
|
|
3981
|
+
return this.apiUrl;
|
|
3965
3982
|
}
|
|
3966
3983
|
/**
|
|
3967
3984
|
* Get the key type (channel, scene, or null if disabled)
|
|
@@ -4028,7 +4045,7 @@ var StaticTVClient = class {
|
|
|
4028
4045
|
* @internal
|
|
4029
4046
|
*/
|
|
4030
4047
|
async request(endpoint, options = {}) {
|
|
4031
|
-
const url = `${this.
|
|
4048
|
+
const url = `${this.apiUrl}${endpoint}`;
|
|
4032
4049
|
return request(url, {
|
|
4033
4050
|
...options,
|
|
4034
4051
|
headers: {
|
|
@@ -4278,12 +4295,8 @@ var StaticTVClient = class {
|
|
|
4278
4295
|
}
|
|
4279
4296
|
if (hasCallback) {
|
|
4280
4297
|
this.config.onVideoPlay(video.src);
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
} else {
|
|
4284
|
-
this._streamVerified = true;
|
|
4285
|
-
this._pendingVideoData = null;
|
|
4286
|
-
}
|
|
4298
|
+
this._streamVerified = true;
|
|
4299
|
+
this._pendingVideoData = null;
|
|
4287
4300
|
}
|
|
4288
4301
|
if (this.guideUI) {
|
|
4289
4302
|
this.guideUI.currentVideoId = video.id;
|
package/package.json
CHANGED