@thestatic-tv/dcl-sdk 2.10.0 → 2.11.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.js CHANGED
@@ -265,6 +265,7 @@ var import_Runtime = require("~system/Runtime");
265
265
  var PARCEL_SIZE = 16;
266
266
  var EDGE_STRIP = 1;
267
267
  var WALL_TOP_MAX = 32;
268
+ var GROUND_REACH = 3;
268
269
  function heightLimit(parcels) {
269
270
  return Math.log2(parcels + 1) * 20;
270
271
  }
@@ -311,13 +312,25 @@ function wallBoxes(rects, strip = EDGE_STRIP, top = wallTop(rects.length)) {
311
312
  function inParcels(p, rects) {
312
313
  return rects.some((r) => p.x >= r.minX && p.x <= r.maxX && p.z >= r.minZ && p.z <= r.maxZ);
313
314
  }
314
- function insideWalls(p, boxes) {
315
- return boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ && p.y < b.top);
315
+ function spawnPointOf(metadata) {
316
+ const points = metadata?.spawnPoints;
317
+ if (!Array.isArray(points) || points.length === 0) return null;
318
+ const chosen = points.find((s) => s && s.default === true) || points[0];
319
+ const position = chosen?.position;
320
+ const coordinate = (v) => {
321
+ const values = (Array.isArray(v) ? v : [v]).filter((n) => typeof n === "number" && Number.isFinite(n));
322
+ return values.length === 0 ? null : (Math.min(...values) + Math.max(...values)) / 2;
323
+ };
324
+ const x = coordinate(position?.x);
325
+ const y = coordinate(position?.y);
326
+ const z = coordinate(position?.z);
327
+ return x === null || y === null || z === null ? null : { x, y, z };
316
328
  }
317
329
  var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
318
- function ejectPoint(boxes, rects, from) {
330
+ function entryPoint(boxes, rects, spawn, from) {
319
331
  const IN = 0.5;
320
- const p = from || { x: 0, y: 0, z: 0 };
332
+ const target = spawn || from || { x: 0, y: 0, z: 0 };
333
+ const y = spawn ? Math.max(0, spawn.y) : 0;
321
334
  let best = null;
322
335
  let bestDistance = Infinity;
323
336
  rects.forEach((rect, i) => {
@@ -325,20 +338,26 @@ function ejectPoint(boxes, rects, from) {
325
338
  if (!b) return;
326
339
  const along = (lo, hi, v) => clamp(v, lo + IN, hi - IN);
327
340
  for (const side of outerSides(rect, rects)) {
328
- const point = side === "west" ? { x: b.minX + IN, z: along(b.minZ, b.maxZ, p.z) } : side === "east" ? { x: b.maxX - IN, z: along(b.minZ, b.maxZ, p.z) } : side === "south" ? { x: along(b.minX, b.maxX, p.x), z: b.minZ + IN } : { x: along(b.minX, b.maxX, p.x), z: b.maxZ - IN };
329
- const distance = Math.hypot(point.x - p.x, point.z - p.z);
341
+ const point = side === "west" ? { x: (rect.minX + b.minX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "east" ? { x: (rect.maxX + b.maxX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "south" ? { x: along(b.minX, b.maxX, target.x), z: (rect.minZ + b.minZ) / 2 } : { x: along(b.minX, b.maxX, target.x), z: (rect.maxZ + b.maxZ) / 2 };
342
+ const distance = Math.hypot(point.x - target.x, point.z - target.z);
330
343
  if (distance < bestDistance) {
331
344
  bestDistance = distance;
332
- best = { x: point.x, y: b.top + 1, z: point.z };
345
+ best = { x: point.x, y, z: point.z };
333
346
  }
334
347
  }
335
348
  });
336
349
  return best;
337
350
  }
351
+ function mustMoveToEntry(p, boxes, rects, entryY) {
352
+ if (!inParcels(p, rects)) return false;
353
+ const overWall = boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ);
354
+ return overWall || p.y > entryY + GROUND_REACH;
355
+ }
338
356
 
339
357
  // src/utils/bounds.ts
340
358
  var cachedBounds = null;
341
359
  var cachedParcelRects = [];
360
+ var cachedSpawn = null;
342
361
  var boundsInitialized = false;
343
362
  var boundsError = false;
344
363
  function parseParcel(parcel) {
@@ -364,6 +383,7 @@ async function getSceneBounds() {
364
383
  const metadata = JSON.parse(sceneInfo.metadataJson);
365
384
  parcels = metadata?.scene?.parcels || [];
366
385
  baseParcel = metadata?.scene?.base;
386
+ cachedSpawn = spawnPointOf(metadata);
367
387
  }
368
388
  if (parcels.length === 0) {
369
389
  boundsError = true;
@@ -418,6 +438,9 @@ function isPlayerInBounds(_bounds) {
418
438
  function getParcelRects() {
419
439
  return cachedParcelRects.map((r) => ({ ...r }));
420
440
  }
441
+ function getSpawnPoint() {
442
+ return cachedSpawn ? { ...cachedSpawn } : null;
443
+ }
421
444
  function getPlayerPosition() {
422
445
  try {
423
446
  const transform = import_ecs2.Transform.getOrNull(import_ecs2.engine.PlayerEntity);
@@ -1089,6 +1112,216 @@ var FramesModule = class {
1089
1112
  }
1090
1113
  };
1091
1114
 
1115
+ // src/modules/stream-link.ts
1116
+ var LOCKED_LINE = "LOCKED: TheStatic.tv citizens";
1117
+ var UNAVAILABLE_LINE = "Stream link unavailable";
1118
+ var REASK_BEFORE_MS = 10 * 60 * 1e3;
1119
+ var REASK_CHECK_MS = 15 * 1e3;
1120
+ var REASK_RETRY_MS = 60 * 1e3;
1121
+ var CHANNEL_MAX = 100;
1122
+ function channelOf(value) {
1123
+ return typeof value === "string" && value !== "" && value.length <= CHANNEL_MAX ? value : null;
1124
+ }
1125
+ var StreamLinkModule = class {
1126
+ constructor(deps) {
1127
+ this.inFlight = /* @__PURE__ */ new Map();
1128
+ this.current = null;
1129
+ this.gen = 0;
1130
+ this.timerId = null;
1131
+ this.deps = deps;
1132
+ }
1133
+ now() {
1134
+ return this.deps.now ? this.deps.now() : Date.now();
1135
+ }
1136
+ log(msg, ...args) {
1137
+ this.deps.log?.(msg, ...args);
1138
+ }
1139
+ /** The channel of the locked play going on, or null */
1140
+ get playing() {
1141
+ return this.current ? this.current.channel : null;
1142
+ }
1143
+ /**
1144
+ * Ask the door for a channel's link, signed as the visitor. One request in flight per channel: an ask while one is
1145
+ * out gets the same answer. A blocked visitor gets 'blocked' and nothing is sent.
1146
+ */
1147
+ ask(channel) {
1148
+ if (this.deps.blocked()) return Promise.resolve({ ok: false, reason: "blocked" });
1149
+ const pending = this.inFlight.get(channel);
1150
+ if (pending) return pending;
1151
+ const request2 = this.request(channel).finally(() => {
1152
+ this.inFlight.delete(channel);
1153
+ });
1154
+ this.inFlight.set(channel, request2);
1155
+ return request2;
1156
+ }
1157
+ async request(channel) {
1158
+ const url = this.deps.doorUrl();
1159
+ if (!url) {
1160
+ this.log("Stream link: no scene id - cannot ask");
1161
+ return { ok: false, reason: "unavailable" };
1162
+ }
1163
+ try {
1164
+ const res = await this.deps.post(url, JSON.stringify({ channel }));
1165
+ let data = {};
1166
+ try {
1167
+ data = await res.json();
1168
+ } catch {
1169
+ }
1170
+ if (res.ok) {
1171
+ const link = data && typeof data.url === "string" ? data.url : "";
1172
+ const expiresAt = data && typeof data.expiresAt === "number" && Number.isFinite(data.expiresAt) ? data.expiresAt : null;
1173
+ if (!link.startsWith("https://")) {
1174
+ this.log("Stream link: an answer with no https url", res.status);
1175
+ return { ok: false, reason: "unavailable", status: res.status };
1176
+ }
1177
+ return { ok: true, url: link, expiresAt };
1178
+ }
1179
+ if (res.status === 403) {
1180
+ return { ok: false, reason: data?.reason === "guest" ? "guest" : "not-admitted", status: 403 };
1181
+ }
1182
+ this.log("Stream link: the door answered", res.status, data?.error);
1183
+ return { ok: false, reason: "unavailable", status: res.status };
1184
+ } catch (err) {
1185
+ this.log("Stream link: request failed", err);
1186
+ return { ok: false, reason: "unavailable" };
1187
+ }
1188
+ }
1189
+ /**
1190
+ * Play a locked channel: ask for its link and hand it to deliver, then keep it fresh while this play goes on. Ends
1191
+ * any locked play before it. A blocked visitor asks nothing; an invalid channel plays nothing.
1192
+ */
1193
+ play(channel, handlers) {
1194
+ this.cancel();
1195
+ const slug = channelOf(channel);
1196
+ if (!slug) {
1197
+ this.log("Stream link: a locked play names no channel - nothing plays");
1198
+ return;
1199
+ }
1200
+ if (this.deps.blocked()) return;
1201
+ const gen = ++this.gen;
1202
+ this.current = { gen, channel: slug, handlers, url: null, nextAskAt: null, lastAskAt: this.now(), asking: true };
1203
+ this.ask(slug).then((answer) => this.first(gen, answer)).catch(() => {
1204
+ });
1205
+ }
1206
+ /** The first answer for play gen: the link plays, or the notice says why not */
1207
+ first(gen, answer) {
1208
+ const play = this.current;
1209
+ if (!play || play.gen !== gen) return;
1210
+ play.asking = false;
1211
+ if (answer.ok && !this.deps.blocked()) {
1212
+ this.deliver(play, answer.url, answer.expiresAt);
1213
+ return;
1214
+ }
1215
+ this.end();
1216
+ if (!answer.ok && answer.reason !== "blocked") this.fail(play, answer.reason);
1217
+ }
1218
+ /** A re-ask's answer: a new link plays in place of the old; a refusal stops the play; a failure tries again later */
1219
+ again(gen, answer) {
1220
+ const play = this.current;
1221
+ if (!play || play.gen !== gen) return;
1222
+ play.asking = false;
1223
+ if (this.deps.blocked()) {
1224
+ this.cancel();
1225
+ return;
1226
+ }
1227
+ if (answer.ok) {
1228
+ this.deliver(play, answer.url, answer.expiresAt);
1229
+ return;
1230
+ }
1231
+ if (answer.reason === "guest" || answer.reason === "not-admitted") {
1232
+ this.log("Stream link: the re-ask was refused - stopping", play.channel);
1233
+ this.end();
1234
+ this.fail(play, answer.reason);
1235
+ try {
1236
+ play.handlers.stop?.();
1237
+ } catch (err) {
1238
+ this.log("Stream link: stop failed", err);
1239
+ }
1240
+ return;
1241
+ }
1242
+ play.nextAskAt = this.now() + REASK_RETRY_MS;
1243
+ }
1244
+ deliver(play, url, expiresAt) {
1245
+ const switched = url !== play.url;
1246
+ play.url = url;
1247
+ if (expiresAt === null) {
1248
+ play.nextAskAt = null;
1249
+ this.stopTimer();
1250
+ } else {
1251
+ play.nextAskAt = Math.max(play.lastAskAt + REASK_RETRY_MS, expiresAt * 1e3 - REASK_BEFORE_MS);
1252
+ this.startTimer();
1253
+ }
1254
+ if (!switched) return;
1255
+ try {
1256
+ play.handlers.deliver(url);
1257
+ } catch (err) {
1258
+ this.log("Stream link: deliver failed", err);
1259
+ }
1260
+ }
1261
+ fail(play, reason) {
1262
+ const line = reason === "guest" || reason === "not-admitted" ? LOCKED_LINE : UNAVAILABLE_LINE;
1263
+ this.deps.notify(line);
1264
+ try {
1265
+ play.handlers.failed?.(line);
1266
+ } catch (err) {
1267
+ this.log("Stream link: failed handler threw", err);
1268
+ }
1269
+ }
1270
+ /** Something played: a url other than this play's own link ends the locked play (the play changed) */
1271
+ playChanged(url) {
1272
+ if (this.current && url !== this.current.url) this.cancel();
1273
+ }
1274
+ /** Ends the locked play, if any: no re-ask, and an answer still on its way is dropped */
1275
+ cancel() {
1276
+ if (!this.current) return;
1277
+ this.log("Stream link: locked play ended", this.current.channel);
1278
+ this.end();
1279
+ }
1280
+ end() {
1281
+ this.current = null;
1282
+ this.stopTimer();
1283
+ }
1284
+ startTimer() {
1285
+ if (this.timerId !== null) return;
1286
+ this.timerId = this.deps.setInterval(() => this.tick(), REASK_CHECK_MS);
1287
+ }
1288
+ stopTimer() {
1289
+ if (this.timerId === null) return;
1290
+ this.deps.clearInterval(this.timerId);
1291
+ this.timerId = null;
1292
+ }
1293
+ /** Every REASK_CHECK_MS while a locked play has a link that expires: a blocked visitor's play ends; a due re-ask goes out */
1294
+ tick() {
1295
+ const play = this.current;
1296
+ if (!play) {
1297
+ this.stopTimer();
1298
+ return;
1299
+ }
1300
+ if (this.deps.blocked()) {
1301
+ this.cancel();
1302
+ return;
1303
+ }
1304
+ if (play.asking || play.nextAskAt === null || this.now() < play.nextAskAt) return;
1305
+ play.asking = true;
1306
+ play.lastAskAt = this.now();
1307
+ this.log("Stream link: asking again before the link expires", play.channel);
1308
+ const gen = play.gen;
1309
+ this.ask(play.channel).then((answer) => this.again(gen, answer)).catch(() => {
1310
+ });
1311
+ }
1312
+ };
1313
+
1314
+ // src/utils/signed-request.ts
1315
+ var import_SignedFetch2 = require("~system/SignedFetch");
1316
+ async function signedRequest(url, init = {}) {
1317
+ const res = await (0, import_SignedFetch2.signedFetch)({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
1318
+ return {
1319
+ ok: res.ok,
1320
+ status: res.status,
1321
+ json: async () => res.body ? JSON.parse(res.body) : {}
1322
+ };
1323
+ }
1324
+
1092
1325
  // src/ui/guide-ui.tsx
1093
1326
  var import_react_ecs2 = __toESM(require("@dcl/sdk/react-ecs"));
1094
1327
  var import_math3 = require("@dcl/sdk/math");
@@ -1334,6 +1567,10 @@ function truncateText(text, maxLength) {
1334
1567
  }
1335
1568
 
1336
1569
  // src/ui/guide-ui.tsx
1570
+ function withLock(mapped, v, fallback) {
1571
+ if (v.locked !== true) return mapped;
1572
+ return { ...mapped, src: "", locked: true, channel: v.slug || v.channelId || fallback };
1573
+ }
1337
1574
  var GuideUIModule = class {
1338
1575
  constructor(client, config = {}) {
1339
1576
  // Visibility state
@@ -1498,7 +1735,7 @@ var GuideUIModule = class {
1498
1735
  for (const [slug, video] of Object.entries(data.videoMap)) {
1499
1736
  const v = video;
1500
1737
  const src = v.src || v.liveStreamUrl || "";
1501
- const mapped = {
1738
+ const mapped = withLock({
1502
1739
  id: v.id || slug,
1503
1740
  name: v.name || v.title || "Unknown",
1504
1741
  src,
@@ -1511,7 +1748,7 @@ var GuideUIModule = class {
1511
1748
  requiresAuth: v.requiresAuth,
1512
1749
  // An 18+ channel or one of its VODs (thestatic.tv's flag since 2026-10-15): it stays listed and asks first
1513
1750
  isNsfw: v.isNsfw === true
1514
- };
1751
+ }, v, slug);
1515
1752
  videos.push(mapped);
1516
1753
  if (mapped.isLive) {
1517
1754
  liveVideos.push(mapped);
@@ -1524,7 +1761,7 @@ var GuideUIModule = class {
1524
1761
  if (pl.name === "NODES") continue;
1525
1762
  playlists.push({
1526
1763
  name: pl.name,
1527
- videos: (pl.videos || []).map((v) => ({
1764
+ videos: (pl.videos || []).map((v) => withLock({
1528
1765
  id: v.id,
1529
1766
  name: v.name || v.title || "Unknown",
1530
1767
  src: v.src || v.liveStreamUrl || "",
@@ -1534,7 +1771,7 @@ var GuideUIModule = class {
1534
1771
  duration: v.duration,
1535
1772
  requiresAuth: v.requiresAuth,
1536
1773
  isNsfw: v.isNsfw === true
1537
- }))
1774
+ }, v, v.id))
1538
1775
  });
1539
1776
  }
1540
1777
  }
@@ -1959,6 +2196,14 @@ var GuideUIModule = class {
1959
2196
  import_react_ecs2.default.createElement(import_react_ecs2.Label, { value: "LIVE", fontSize: this.s(10), color: THEME.colors.white })
1960
2197
  ]
1961
2198
  })
2199
+ ] : [],
2200
+ // A locked channel (2026-11-20): its badge, the words a refused pick shows - one line, 12px in the 260px card
2201
+ ...video.locked === true ? [
2202
+ import_react_ecs2.default.createElement(import_react_ecs2.UiEntity, {
2203
+ key: "locked",
2204
+ uiTransform: { height: this.s(16), marginTop: 4 },
2205
+ uiText: { value: LOCKED_LINE, fontSize: this.s(12), color: THEME.colors.yellow }
2206
+ })
1962
2207
  ] : []
1963
2208
  ]
1964
2209
  }),
@@ -2125,7 +2370,7 @@ var GuideUIModule = class {
2125
2370
  // src/ui/chat-ui.tsx
2126
2371
  var import_react_ecs3 = __toESM(require("@dcl/sdk/react-ecs"));
2127
2372
  var import_math4 = require("@dcl/sdk/math");
2128
- var import_SignedFetch2 = require("~system/SignedFetch");
2373
+ var import_SignedFetch3 = require("~system/SignedFetch");
2129
2374
  var import_players = require("@dcl/sdk/players");
2130
2375
  var import_RestrictedActions3 = require("~system/RestrictedActions");
2131
2376
  var POLL_INTERVAL_ACTIVE = 5e3;
@@ -2312,7 +2557,7 @@ var ChatUIModule = class {
2312
2557
  this.isSigningIn = true;
2313
2558
  try {
2314
2559
  const baseUrl = this.getBaseUrl();
2315
- const response = await (0, import_SignedFetch2.signedFetch)({
2560
+ const response = await (0, import_SignedFetch3.signedFetch)({
2316
2561
  url: `${baseUrl}/api/auth/dcl`,
2317
2562
  init: {
2318
2563
  method: "POST",
@@ -2414,7 +2659,7 @@ var ChatUIModule = class {
2414
2659
  this.inputText = "";
2415
2660
  try {
2416
2661
  const baseUrl = this.getBaseUrl();
2417
- const response = await (0, import_SignedFetch2.signedFetch)({
2662
+ const response = await (0, import_SignedFetch3.signedFetch)({
2418
2663
  url: `${baseUrl}/api/chat/send`,
2419
2664
  init: {
2420
2665
  method: "POST",
@@ -2964,7 +3209,6 @@ var import_react_ecs6 = __toESM(require("@dcl/sdk/react-ecs"));
2964
3209
  var import_math7 = require("@dcl/sdk/math");
2965
3210
  var import_players2 = require("@dcl/sdk/players");
2966
3211
  var import_RestrictedActions6 = require("~system/RestrictedActions");
2967
- var import_SignedFetch3 = require("~system/SignedFetch");
2968
3212
 
2969
3213
  // src/ui/ui-renderer.tsx
2970
3214
  var import_react_ecs4 = __toESM(require("@dcl/sdk/react-ecs"));
@@ -3279,6 +3523,7 @@ var ModerationModule = class {
3279
3523
  this.readWaiters = [];
3280
3524
  this.rects = [];
3281
3525
  this.boxes = [];
3526
+ this.spawn = null;
3282
3527
  this.wallEntities = [];
3283
3528
  this.lastBlocked = false;
3284
3529
  this.lastStanding = "clear";
@@ -3288,7 +3533,7 @@ var ModerationModule = class {
3288
3533
  this.wasInScene = null;
3289
3534
  this.sinceCheck = 0;
3290
3535
  this.started = false;
3291
- /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
3536
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor out of place moved to the front entry */
3292
3537
  this.system = (dt) => {
3293
3538
  if (this.hintDueAt !== null && this.now() >= this.hintDueAt) {
3294
3539
  this.hintDueAt = null;
@@ -3316,10 +3561,10 @@ var ModerationModule = class {
3316
3561
  if (inScene && now - this.lastReadAt >= REREAD_MS) this.readPending = true;
3317
3562
  this.wasInScene = inScene;
3318
3563
  this.tryRead();
3319
- if (me && this.blocked && insideWalls(me, this.boxes)) {
3320
- const to = ejectPoint(this.boxes, this.rects, me);
3321
- if (to) {
3322
- this.log("Blocked and inside the walls - moving above them", to);
3564
+ if (me && this.blocked) {
3565
+ const to = entryPoint(this.boxes, this.rects, this.spawn, me);
3566
+ if (to && mustMoveToEntry(me, this.boxes, this.rects, to.y)) {
3567
+ this.log("Blocked and inside the scene - moving to the front entry", to);
3323
3568
  Promise.resolve((0, import_RestrictedActions5.movePlayerTo)({ newRelativePosition: import_math6.Vector3.create(to.x, to.y, to.z) })).catch(() => {
3324
3569
  });
3325
3570
  }
@@ -3342,6 +3587,7 @@ var ModerationModule = class {
3342
3587
  await getSceneBounds();
3343
3588
  this.rects = getParcelRects();
3344
3589
  this.boxes = wallBoxes(this.rects);
3590
+ this.spawn = getSpawnPoint();
3345
3591
  } catch {
3346
3592
  }
3347
3593
  this.sync();
@@ -3481,6 +3727,7 @@ var ModerationModule = class {
3481
3727
  };
3482
3728
 
3483
3729
  // src/ui/admin-panel-ui.tsx
3730
+ var VIDEO_PLAY_TYPES = /* @__PURE__ */ new Set(["videoPlay", "videoSetUrl", "videoPlaySlot"]);
3484
3731
  var FIGURE_NAMES = ["recordings", "vaulted", "slugKeyedLeft", "pendingReports"];
3485
3732
  function figuresOf(value) {
3486
3733
  const figures = value?.figures;
@@ -3580,6 +3827,11 @@ var AdminPanelUIModule = class {
3580
3827
  this.broadcastStatus = "";
3581
3828
  /** The url the screen last played - the scene's current one from the video state at load, or the last play here - which PLAYBACK Play sends */
3582
3829
  this.currentVideoUrl = null;
3830
+ /**
3831
+ * The locked channel the screen last played (2026-11-20), in place of a url: PLAYBACK Play queues it again as
3832
+ * `{ channel, locked: true }` - a locked channel's link is this visitor's own and never goes into the queue
3833
+ */
3834
+ this.currentLockedChannel = null;
3583
3835
  // Scene controls (2026-11-18): the scene's own declaration, each control's current option on this copy, the tab's
3584
3836
  // status line, and the once-a-load gates for the declaration's upload and the saved state's read
3585
3837
  this.controls = [];
@@ -3707,9 +3959,9 @@ var AdminPanelUIModule = class {
3707
3959
  )), /* @__PURE__ */ import_react_ecs6.default.createElement(import_react_ecs6.UiEntity, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ import_react_ecs6.default.createElement(import_react_ecs6.Label, { value: "HLS Playback:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ import_react_ecs6.default.createElement(
3708
3960
  import_react_ecs6.Label,
3709
3961
  {
3710
- value: this.streamData.hlsUrl || "Not available",
3962
+ value: this.streamData.locked === true ? LOCKED_LINE : this.streamData.hlsUrl || "Not available",
3711
3963
  fontSize: t.label,
3712
- color: this.streamData.hlsUrl ? C2.green : C2.textDim,
3964
+ color: this.streamData.locked === true ? C2.yellow : this.streamData.hlsUrl ? C2.green : C2.textDim,
3713
3965
  uiTransform: { margin: { left: 6 } }
3714
3966
  }
3715
3967
  )), /* @__PURE__ */ import_react_ecs6.default.createElement(import_react_ecs6.UiEntity, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, !this.streamData.isLive && /* @__PURE__ */ import_react_ecs6.default.createElement(
@@ -3732,7 +3984,7 @@ var AdminPanelUIModule = class {
3732
3984
  color: C2.text,
3733
3985
  onMouseDown: () => this.stopStream()
3734
3986
  }
3735
- ), this.streamData.isLive && this.streamData.hlsUrl && /* @__PURE__ */ import_react_ecs6.default.createElement(
3987
+ ), this.streamData.isLive && (this.streamData.hlsUrl || this.streamData.locked === true) && /* @__PURE__ */ import_react_ecs6.default.createElement(
3736
3988
  import_react_ecs6.Button,
3737
3989
  {
3738
3990
  uiTransform: { width: this.s(100), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
@@ -3740,7 +3992,7 @@ var AdminPanelUIModule = class {
3740
3992
  value: "Play on Screen",
3741
3993
  fontSize: t.buttonSmall,
3742
3994
  color: C2.text,
3743
- onMouseDown: () => this.playStreamOnScreen(this.streamData.hlsUrl)
3995
+ onMouseDown: () => this.playStreamOnScreen()
3744
3996
  }
3745
3997
  )), /* @__PURE__ */ import_react_ecs6.default.createElement(import_react_ecs6.UiEntity, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, /* @__PURE__ */ import_react_ecs6.default.createElement(
3746
3998
  import_react_ecs6.Button,
@@ -3833,7 +4085,7 @@ var AdminPanelUIModule = class {
3833
4085
  {
3834
4086
  value: this.videoStatus,
3835
4087
  fontSize: t.status,
3836
- color: this.videoStatus.startsWith("Not sent") ? C2.red : C2.green,
4088
+ color: this.videoStatus.startsWith("Not sent") || this.videoStatus === LOCKED_LINE || this.videoStatus === UNAVAILABLE_LINE ? C2.red : C2.green,
3837
4089
  uiTransform: { height: this.s(18), margin: { bottom: 6 } }
3838
4090
  }
3839
4091
  ), /* @__PURE__ */ import_react_ecs6.default.createElement(this.SectionHead, { label: "PLAYBACK", color: C2.green }), /* @__PURE__ */ import_react_ecs6.default.createElement(import_react_ecs6.UiEntity, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ import_react_ecs6.default.createElement(
@@ -4376,8 +4628,37 @@ var AdminPanelUIModule = class {
4376
4628
  playUrl(url) {
4377
4629
  if (this.moderation.blocked) return;
4378
4630
  this.currentVideoUrl = url;
4631
+ this.currentLockedChannel = null;
4379
4632
  this.config.onVideoPlay?.(url);
4380
4633
  }
4634
+ /**
4635
+ * A locked channel's play (thestatic.tv's stream lock, 2026-11-20): a queued video command carrying
4636
+ * `{ channel, locked: true }`, the owner's Play on Screen for a locked stream, a locked slot. This copy asks
4637
+ * thestatic.tv's door for the link, signed as this visitor (the client's stream link: one request in flight per
4638
+ * channel, the re-ask before it expires), and plays it through onVideoPlay only when admitted. A refusal plays
4639
+ * nothing; the notice and this tab's video line say LOCKED: TheStatic.tv citizens. A blocked visitor asks nothing.
4640
+ * The link itself is never kept for PLAYBACK Play or sent to the queue - the channel is.
4641
+ */
4642
+ playLocked(channel) {
4643
+ if (this.moderation.blocked) return;
4644
+ const slug = channelOf(channel);
4645
+ if (!slug) {
4646
+ this.log("A locked play names no channel - nothing plays");
4647
+ return;
4648
+ }
4649
+ this.currentLockedChannel = slug;
4650
+ this.currentVideoUrl = null;
4651
+ this.client._playLockedChannel?.(slug, {
4652
+ deliver: (url) => {
4653
+ if (this.moderation.blocked) return;
4654
+ this.config.onVideoPlay?.(url);
4655
+ },
4656
+ stop: () => this.config.onVideoStop?.(),
4657
+ failed: (line) => {
4658
+ this.videoStatus = line;
4659
+ }
4660
+ });
4661
+ }
4381
4662
  /**
4382
4663
  * Toggle the admin panel open/closed
4383
4664
  */
@@ -4588,15 +4869,12 @@ var AdminPanelUIModule = class {
4588
4869
  * Every gated admin call is a DCL signed fetch (thestatic.tv STATIC-01, 2026-10-07): the
4589
4870
  * explorer signs it with the player's identity, and the server checks the signature and that it
4590
4871
  * came from the scene deployed at this scene's registered location. A wallet named in a query or
4591
- * body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites.
4872
+ * body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites. The
4873
+ * request itself lives in utils/signed-request.ts since 2026-11-20 (it was here), so the locked
4874
+ * channel's door - which a Standard scene asks too, with no panel - goes through the same one.
4592
4875
  */
4593
4876
  async signedRequest(url, init = {}) {
4594
- const res = await (0, import_SignedFetch3.signedFetch)({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
4595
- return {
4596
- ok: res.ok,
4597
- status: res.status,
4598
- json: async () => res.body ? JSON.parse(res.body) : {}
4599
- };
4877
+ return signedRequest(url, init);
4600
4878
  }
4601
4879
  /**
4602
4880
  * Every visitor's copy reads the scene's queue (a public GET, every 5 s). Since 2026-11-18 the poll sends the server's
@@ -4649,12 +4927,18 @@ var AdminPanelUIModule = class {
4649
4927
  } else if (cmd.type === "privateMode" && this.venue) {
4650
4928
  this.log("Received privateMode - re-reading my standing");
4651
4929
  this.moderation.handleCommand(cmd.type, cmd.payload);
4930
+ } else if (VIDEO_PLAY_TYPES.has(cmd.type) && cmd.payload?.locked === true) {
4931
+ this.log("Received locked play:", cmd.type, cmd.payload.channel);
4932
+ this.playLocked(cmd.payload.channel);
4652
4933
  } else if ((cmd.type === "videoPlay" || cmd.type === "videoSetUrl") && cmd.payload?.url) {
4653
4934
  this.log("Received video play:", cmd.type, cmd.payload.url);
4654
4935
  this.playUrl(cmd.payload.url);
4655
4936
  } else if (cmd.type === "videoStop" || cmd.type === "videoClear") {
4656
4937
  this.log("Received video stop/clear:", cmd.type);
4657
- if (cmd.type === "videoClear") this.currentVideoUrl = null;
4938
+ if (cmd.type === "videoClear") {
4939
+ this.currentVideoUrl = null;
4940
+ this.currentLockedChannel = null;
4941
+ }
4658
4942
  this.config.onVideoStop?.();
4659
4943
  } else if (cmd.type === "videoPlaySlot" && cmd.payload?.slot) {
4660
4944
  const slotId = cmd.payload.slot;
@@ -4718,6 +5002,11 @@ var AdminPanelUIModule = class {
4718
5002
  videoSlots: data.videoSlots || {}
4719
5003
  };
4720
5004
  if (typeof data.currentVideoUrl === "string" && data.currentVideoUrl !== "") this.currentVideoUrl = data.currentVideoUrl;
5005
+ const lockedCurrent = data.currentVideo?.locked === true ? channelOf(data.currentVideo.channel) : null;
5006
+ if (lockedCurrent) {
5007
+ this.currentLockedChannel = lockedCurrent;
5008
+ this.currentVideoUrl = null;
5009
+ }
4721
5010
  this.videoStateFetched = true;
4722
5011
  this.log("Video state fetched:", this.videoState.defaultSlot || "no default");
4723
5012
  }
@@ -4730,6 +5019,11 @@ var AdminPanelUIModule = class {
4730
5019
  */
4731
5020
  playSlot(slotId) {
4732
5021
  const slot = this.videoState?.videoSlots?.[slotId];
5022
+ if (slot?.locked === true) {
5023
+ this.log("Playing locked slot:", slotId);
5024
+ this.playLocked(slot.slug ?? slot.channel);
5025
+ return;
5026
+ }
4733
5027
  if (slot?.url) {
4734
5028
  this.log("Playing slot:", slotId, slot.url);
4735
5029
  this.playUrl(slot.url);
@@ -4745,7 +5039,10 @@ var AdminPanelUIModule = class {
4745
5039
  if (!this.videoState?.defaultSlot) return;
4746
5040
  const defaultSlot = this.videoState.defaultSlot;
4747
5041
  const slot = this.videoState.videoSlots?.[defaultSlot];
4748
- if (slot?.url) {
5042
+ if (slot?.locked === true) {
5043
+ this.log("Auto-playing locked default slot:", defaultSlot);
5044
+ this.playLocked(slot.slug ?? slot.channel);
5045
+ } else if (slot?.url) {
4749
5046
  this.log("Auto-playing default slot:", defaultSlot);
4750
5047
  this.playUrl(slot.url);
4751
5048
  }
@@ -5225,8 +5522,25 @@ var AdminPanelUIModule = class {
5225
5522
  this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5226
5523
  });
5227
5524
  }
5228
- /** Play on Screen: the scene's own live stream, as PLAY NOW with its HLS url (what the scene's page sends for it) */
5229
- playStreamOnScreen(url) {
5525
+ /**
5526
+ * Play on Screen: the scene's own live stream, as PLAY NOW with its HLS url (what the scene's page sends for it). A
5527
+ * locked stream (2026-11-20: the /stream answer says locked, with its slug and no hlsUrl) plays here through the
5528
+ * link asked for signed as the owner, and queues `videoSetUrl { channel, locked: true }` - never a url, so every
5529
+ * visitor's copy asks for its own link and only the admitted play it.
5530
+ */
5531
+ playStreamOnScreen() {
5532
+ const data = this.streamData;
5533
+ if (!data) return;
5534
+ if (data.locked === true) {
5535
+ const channel = channelOf(data.slug ?? data.channelId);
5536
+ if (!channel) return;
5537
+ this.playLocked(channel);
5538
+ this.sendSceneCommand("videoSetUrl", { channel, locked: true }, this.videoLine).catch(() => {
5539
+ });
5540
+ return;
5541
+ }
5542
+ const url = data.hlsUrl;
5543
+ if (!url) return;
5230
5544
  this.playUrl(url);
5231
5545
  this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5232
5546
  });
@@ -5244,6 +5558,13 @@ var AdminPanelUIModule = class {
5244
5558
  */
5245
5559
  playbackPlay() {
5246
5560
  this.config.onCommand?.("videoPlay", { playing: true });
5561
+ const locked = this.currentLockedChannel;
5562
+ if (locked) {
5563
+ this.playLocked(locked);
5564
+ this.sendSceneCommand("videoPlay", { channel: locked, locked: true }, this.videoLine).catch(() => {
5565
+ });
5566
+ return;
5567
+ }
5247
5568
  const url = this.currentVideoUrl;
5248
5569
  if (!url) {
5249
5570
  this.videoStatus = "Not sent: no video";
@@ -5267,6 +5588,7 @@ var AdminPanelUIModule = class {
5267
5588
  resetDefault() {
5268
5589
  this.config.onCommand?.("videoClear", {});
5269
5590
  this.currentVideoUrl = null;
5591
+ this.currentLockedChannel = null;
5270
5592
  this.config.onVideoStop?.();
5271
5593
  this.sendSceneCommand("videoClear", {}, this.videoLine).catch(() => {
5272
5594
  });
@@ -5468,6 +5790,18 @@ var StaticTVClient = class {
5468
5790
  this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
5469
5791
  this.frames = new FramesModule(this);
5470
5792
  if (config.frames) this.frames.register(config.frames);
5793
+ this.streamLink = new StreamLinkModule({
5794
+ doorUrl: () => {
5795
+ const sceneId = this.getSceneId();
5796
+ return sceneId ? `${this.apiUrl}/scene/${encodeURIComponent(sceneId)}/stream/play` : null;
5797
+ },
5798
+ post: (url, body) => signedRequest(url, { method: "POST", headers: { "Content-Type": "application/json" }, body }),
5799
+ blocked: () => this.isVisitorBlocked,
5800
+ notify: (line) => this.showNotification(line),
5801
+ setInterval: dclSetInterval,
5802
+ clearInterval: dclClearInterval,
5803
+ log: (msg, ...args) => this.log(msg, ...args)
5804
+ });
5471
5805
  if (!config.apiKey) {
5472
5806
  this._disabled = true;
5473
5807
  this._keyType = null;
@@ -5659,6 +5993,7 @@ var StaticTVClient = class {
5659
5993
  */
5660
5994
  playVideo(url) {
5661
5995
  if (this.isVisitorBlocked) return;
5996
+ this.streamLink.playChanged(url);
5662
5997
  const screen = this.config.videoScreen;
5663
5998
  if (screen !== void 0) {
5664
5999
  this.log(`Playing video: ${url}`);
@@ -5683,6 +6018,7 @@ var StaticTVClient = class {
5683
6018
  */
5684
6019
  stopVideo() {
5685
6020
  const screen = this.config.videoScreen;
6021
+ this.streamLink.cancel();
5686
6022
  this._pendingVideoData = null;
5687
6023
  this._streamVerified = false;
5688
6024
  this._clearVerificationTimeout();
@@ -5841,10 +6177,48 @@ var StaticTVClient = class {
5841
6177
  _handleGuideVideoSelect(video) {
5842
6178
  if (!video.src) return;
5843
6179
  if (this.isVisitorBlocked) return;
6180
+ this.streamLink.cancel();
6181
+ this._playGuideEntry(video);
6182
+ }
6183
+ /**
6184
+ * A guide entry with its url, onto the SDK's player and/or onVideoPlay, with the stream verification - an unlocked
6185
+ * pick's, and a locked one's once its link is in hand (2026-11-20; until then this was _handleGuideVideoSelect's body)
6186
+ * @internal
6187
+ */
6188
+ _playGuideEntry(video) {
5844
6189
  this._pendingVideoData = video;
5845
6190
  const isLiveStream = video.channelId !== void 0 || video.src.includes(".m3u8") || video.src.includes("media.thestatic.tv");
5846
6191
  this._playVideoWithVerification(video, isLiveStream);
5847
6192
  }
6193
+ /**
6194
+ * A locked channel's guide entry picked (thestatic.tv's stream lock, 2026-11-20). It carries no url: the SDK asks
6195
+ * thestatic.tv's door for the link, signed as this visitor, and only with a link in hand does the entry go on - to
6196
+ * the SDK's player and onVideoPlay as an unlocked pick does, and to the scene's own guideUI.onVideoSelect - with the
6197
+ * link as its src. Scenes' own handlers play `video.src` (TheStatic.tv HQ's, the templates'), so handing them the
6198
+ * entry before the answer would play an empty src, and on a refusal play what should not play: a refusal hands
6199
+ * nobody anything and shows LOCKED: TheStatic.tv citizens. Each fresh link before the old one expires goes the same
6200
+ * way (the re-ask); a re-ask refused stops the video. A blocked visitor asks nothing.
6201
+ * @internal
6202
+ */
6203
+ _selectLockedGuideEntry(video) {
6204
+ if (this.isVisitorBlocked) return;
6205
+ this.streamLink.play(video.channel, {
6206
+ deliver: (url) => {
6207
+ const entry = { ...video, src: url };
6208
+ if (this.config.videoScreen !== void 0 || this.config.onVideoPlay) this._playGuideEntry(entry);
6209
+ if (this.config.guideUI?.onVideoSelect) this.config.guideUI.onVideoSelect(entry);
6210
+ },
6211
+ stop: () => this.stopVideo()
6212
+ });
6213
+ }
6214
+ /**
6215
+ * A locked channel's play from the Admin Panel - a queued video command carrying `{ channel, locked: true }`, the
6216
+ * owner's Play on Screen, a locked slot (2026-11-20): the same ask and re-ask as a guide pick, the panel's own hands.
6217
+ * @internal
6218
+ */
6219
+ _playLockedChannel(channel, handlers) {
6220
+ this.streamLink.play(channel, handlers);
6221
+ }
5848
6222
  /**
5849
6223
  * Play video with stream verification for live content
5850
6224
  * Works with both videoScreen (SDK-managed) and onVideoPlay (user-managed) modes.
@@ -5967,6 +6341,7 @@ var StaticTVClient = class {
5967
6341
  this.guideUI?.hide();
5968
6342
  this.chatUI?.hide();
5969
6343
  this.heartbeat?.stopWatching();
6344
+ this.streamLink.cancel();
5970
6345
  this._pendingVideoData = null;
5971
6346
  this._clearVerificationTimeout();
5972
6347
  if (screen !== void 0 && import_ecs5.VideoPlayer.has(screen)) {
@@ -6008,6 +6383,10 @@ var StaticTVClient = class {
6008
6383
  const guideConfig = {
6009
6384
  ...this.config.guideUI,
6010
6385
  onVideoSelect: (video) => {
6386
+ if (video.locked === true) {
6387
+ this._selectLockedGuideEntry(video);
6388
+ return;
6389
+ }
6011
6390
  if (this.config.videoScreen !== void 0 || this.config.onVideoPlay) {
6012
6391
  this._handleGuideVideoSelect(video);
6013
6392
  }
@@ -6323,6 +6702,7 @@ var StaticTVClient = class {
6323
6702
  this.log("StaticTVClient destroyed (was disabled)");
6324
6703
  return;
6325
6704
  }
6705
+ this.streamLink.cancel();
6326
6706
  if (this.heartbeat) {
6327
6707
  this.heartbeat.stopWatching();
6328
6708
  }