@thestatic-tv/dcl-sdk 2.10.1 → 2.11.1

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.mjs CHANGED
@@ -1061,6 +1061,216 @@ var FramesModule = class {
1061
1061
  }
1062
1062
  };
1063
1063
 
1064
+ // src/modules/stream-link.ts
1065
+ var LOCKED_LINE = "LOCKED: TheStatic.tv citizens";
1066
+ var UNAVAILABLE_LINE = "Stream link unavailable";
1067
+ var REASK_BEFORE_MS = 10 * 60 * 1e3;
1068
+ var REASK_CHECK_MS = 15 * 1e3;
1069
+ var REASK_RETRY_MS = 60 * 1e3;
1070
+ var CHANNEL_MAX = 100;
1071
+ function channelOf(value) {
1072
+ return typeof value === "string" && value !== "" && value.length <= CHANNEL_MAX ? value : null;
1073
+ }
1074
+ var StreamLinkModule = class {
1075
+ constructor(deps) {
1076
+ this.inFlight = /* @__PURE__ */ new Map();
1077
+ this.current = null;
1078
+ this.gen = 0;
1079
+ this.timerId = null;
1080
+ this.deps = deps;
1081
+ }
1082
+ now() {
1083
+ return this.deps.now ? this.deps.now() : Date.now();
1084
+ }
1085
+ log(msg, ...args) {
1086
+ this.deps.log?.(msg, ...args);
1087
+ }
1088
+ /** The channel of the locked play going on, or null */
1089
+ get playing() {
1090
+ return this.current ? this.current.channel : null;
1091
+ }
1092
+ /**
1093
+ * Ask the door for a channel's link, signed as the visitor. One request in flight per channel: an ask while one is
1094
+ * out gets the same answer. A blocked visitor gets 'blocked' and nothing is sent.
1095
+ */
1096
+ ask(channel) {
1097
+ if (this.deps.blocked()) return Promise.resolve({ ok: false, reason: "blocked" });
1098
+ const pending = this.inFlight.get(channel);
1099
+ if (pending) return pending;
1100
+ const request2 = this.request(channel).finally(() => {
1101
+ this.inFlight.delete(channel);
1102
+ });
1103
+ this.inFlight.set(channel, request2);
1104
+ return request2;
1105
+ }
1106
+ async request(channel) {
1107
+ const url = this.deps.doorUrl();
1108
+ if (!url) {
1109
+ this.log("Stream link: no scene id - cannot ask");
1110
+ return { ok: false, reason: "unavailable" };
1111
+ }
1112
+ try {
1113
+ const res = await this.deps.post(url, JSON.stringify({ channel }));
1114
+ let data = {};
1115
+ try {
1116
+ data = await res.json();
1117
+ } catch {
1118
+ }
1119
+ if (res.ok) {
1120
+ const link = data && typeof data.url === "string" ? data.url : "";
1121
+ const expiresAt = data && typeof data.expiresAt === "number" && Number.isFinite(data.expiresAt) ? data.expiresAt : null;
1122
+ if (!link.startsWith("https://")) {
1123
+ this.log("Stream link: an answer with no https url", res.status);
1124
+ return { ok: false, reason: "unavailable", status: res.status };
1125
+ }
1126
+ return { ok: true, url: link, expiresAt };
1127
+ }
1128
+ if (res.status === 403) {
1129
+ return { ok: false, reason: data?.reason === "guest" ? "guest" : "not-admitted", status: 403 };
1130
+ }
1131
+ this.log("Stream link: the door answered", res.status, data?.error);
1132
+ return { ok: false, reason: "unavailable", status: res.status };
1133
+ } catch (err) {
1134
+ this.log("Stream link: request failed", err);
1135
+ return { ok: false, reason: "unavailable" };
1136
+ }
1137
+ }
1138
+ /**
1139
+ * Play a locked channel: ask for its link and hand it to deliver, then keep it fresh while this play goes on. Ends
1140
+ * any locked play before it. A blocked visitor asks nothing; an invalid channel plays nothing.
1141
+ */
1142
+ play(channel, handlers) {
1143
+ this.cancel();
1144
+ const slug = channelOf(channel);
1145
+ if (!slug) {
1146
+ this.log("Stream link: a locked play names no channel - nothing plays");
1147
+ return;
1148
+ }
1149
+ if (this.deps.blocked()) return;
1150
+ const gen = ++this.gen;
1151
+ this.current = { gen, channel: slug, handlers, url: null, nextAskAt: null, lastAskAt: this.now(), asking: true };
1152
+ this.ask(slug).then((answer) => this.first(gen, answer)).catch(() => {
1153
+ });
1154
+ }
1155
+ /** The first answer for play gen: the link plays, or the notice says why not */
1156
+ first(gen, answer) {
1157
+ const play = this.current;
1158
+ if (!play || play.gen !== gen) return;
1159
+ play.asking = false;
1160
+ if (answer.ok && !this.deps.blocked()) {
1161
+ this.deliver(play, answer.url, answer.expiresAt);
1162
+ return;
1163
+ }
1164
+ this.end();
1165
+ if (!answer.ok && answer.reason !== "blocked") this.fail(play, answer.reason);
1166
+ }
1167
+ /** A re-ask's answer: a new link plays in place of the old; a refusal stops the play; a failure tries again later */
1168
+ again(gen, answer) {
1169
+ const play = this.current;
1170
+ if (!play || play.gen !== gen) return;
1171
+ play.asking = false;
1172
+ if (this.deps.blocked()) {
1173
+ this.cancel();
1174
+ return;
1175
+ }
1176
+ if (answer.ok) {
1177
+ this.deliver(play, answer.url, answer.expiresAt);
1178
+ return;
1179
+ }
1180
+ if (answer.reason === "guest" || answer.reason === "not-admitted") {
1181
+ this.log("Stream link: the re-ask was refused - stopping", play.channel);
1182
+ this.end();
1183
+ this.fail(play, answer.reason);
1184
+ try {
1185
+ play.handlers.stop?.();
1186
+ } catch (err) {
1187
+ this.log("Stream link: stop failed", err);
1188
+ }
1189
+ return;
1190
+ }
1191
+ play.nextAskAt = this.now() + REASK_RETRY_MS;
1192
+ }
1193
+ deliver(play, url, expiresAt) {
1194
+ const switched = url !== play.url;
1195
+ play.url = url;
1196
+ if (expiresAt === null) {
1197
+ play.nextAskAt = null;
1198
+ this.stopTimer();
1199
+ } else {
1200
+ play.nextAskAt = Math.max(play.lastAskAt + REASK_RETRY_MS, expiresAt * 1e3 - REASK_BEFORE_MS);
1201
+ this.startTimer();
1202
+ }
1203
+ if (!switched) return;
1204
+ try {
1205
+ play.handlers.deliver(url);
1206
+ } catch (err) {
1207
+ this.log("Stream link: deliver failed", err);
1208
+ }
1209
+ }
1210
+ fail(play, reason) {
1211
+ const line = reason === "guest" || reason === "not-admitted" ? LOCKED_LINE : UNAVAILABLE_LINE;
1212
+ this.deps.notify(line);
1213
+ try {
1214
+ play.handlers.failed?.(line);
1215
+ } catch (err) {
1216
+ this.log("Stream link: failed handler threw", err);
1217
+ }
1218
+ }
1219
+ /** Something played: a url other than this play's own link ends the locked play (the play changed) */
1220
+ playChanged(url) {
1221
+ if (this.current && url !== this.current.url) this.cancel();
1222
+ }
1223
+ /** Ends the locked play, if any: no re-ask, and an answer still on its way is dropped */
1224
+ cancel() {
1225
+ if (!this.current) return;
1226
+ this.log("Stream link: locked play ended", this.current.channel);
1227
+ this.end();
1228
+ }
1229
+ end() {
1230
+ this.current = null;
1231
+ this.stopTimer();
1232
+ }
1233
+ startTimer() {
1234
+ if (this.timerId !== null) return;
1235
+ this.timerId = this.deps.setInterval(() => this.tick(), REASK_CHECK_MS);
1236
+ }
1237
+ stopTimer() {
1238
+ if (this.timerId === null) return;
1239
+ this.deps.clearInterval(this.timerId);
1240
+ this.timerId = null;
1241
+ }
1242
+ /** 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 */
1243
+ tick() {
1244
+ const play = this.current;
1245
+ if (!play) {
1246
+ this.stopTimer();
1247
+ return;
1248
+ }
1249
+ if (this.deps.blocked()) {
1250
+ this.cancel();
1251
+ return;
1252
+ }
1253
+ if (play.asking || play.nextAskAt === null || this.now() < play.nextAskAt) return;
1254
+ play.asking = true;
1255
+ play.lastAskAt = this.now();
1256
+ this.log("Stream link: asking again before the link expires", play.channel);
1257
+ const gen = play.gen;
1258
+ this.ask(play.channel).then((answer) => this.again(gen, answer)).catch(() => {
1259
+ });
1260
+ }
1261
+ };
1262
+
1263
+ // src/utils/signed-request.ts
1264
+ import { signedFetch as signedFetch2 } from "~system/SignedFetch";
1265
+ async function signedRequest(url, init = {}) {
1266
+ const res = await signedFetch2({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
1267
+ return {
1268
+ ok: res.ok,
1269
+ status: res.status,
1270
+ json: async () => res.body ? JSON.parse(res.body) : {}
1271
+ };
1272
+ }
1273
+
1064
1274
  // src/ui/guide-ui.tsx
1065
1275
  import ReactEcs2, { UiEntity as UiEntity2, Input as Input2, Label as Label2 } from "@dcl/sdk/react-ecs";
1066
1276
  import { Color4 as Color43 } from "@dcl/sdk/math";
@@ -1306,6 +1516,10 @@ function truncateText(text, maxLength) {
1306
1516
  }
1307
1517
 
1308
1518
  // src/ui/guide-ui.tsx
1519
+ function withLock(mapped, v, fallback) {
1520
+ if (v.locked !== true) return mapped;
1521
+ return { ...mapped, src: "", locked: true, channel: v.slug || v.channelId || fallback };
1522
+ }
1309
1523
  var GuideUIModule = class {
1310
1524
  constructor(client, config = {}) {
1311
1525
  // Visibility state
@@ -1470,7 +1684,7 @@ var GuideUIModule = class {
1470
1684
  for (const [slug, video] of Object.entries(data.videoMap)) {
1471
1685
  const v = video;
1472
1686
  const src = v.src || v.liveStreamUrl || "";
1473
- const mapped = {
1687
+ const mapped = withLock({
1474
1688
  id: v.id || slug,
1475
1689
  name: v.name || v.title || "Unknown",
1476
1690
  src,
@@ -1483,7 +1697,7 @@ var GuideUIModule = class {
1483
1697
  requiresAuth: v.requiresAuth,
1484
1698
  // An 18+ channel or one of its VODs (thestatic.tv's flag since 2026-10-15): it stays listed and asks first
1485
1699
  isNsfw: v.isNsfw === true
1486
- };
1700
+ }, v, slug);
1487
1701
  videos.push(mapped);
1488
1702
  if (mapped.isLive) {
1489
1703
  liveVideos.push(mapped);
@@ -1496,7 +1710,7 @@ var GuideUIModule = class {
1496
1710
  if (pl.name === "NODES") continue;
1497
1711
  playlists.push({
1498
1712
  name: pl.name,
1499
- videos: (pl.videos || []).map((v) => ({
1713
+ videos: (pl.videos || []).map((v) => withLock({
1500
1714
  id: v.id,
1501
1715
  name: v.name || v.title || "Unknown",
1502
1716
  src: v.src || v.liveStreamUrl || "",
@@ -1506,7 +1720,7 @@ var GuideUIModule = class {
1506
1720
  duration: v.duration,
1507
1721
  requiresAuth: v.requiresAuth,
1508
1722
  isNsfw: v.isNsfw === true
1509
- }))
1723
+ }, v, v.id))
1510
1724
  });
1511
1725
  }
1512
1726
  }
@@ -1931,6 +2145,14 @@ var GuideUIModule = class {
1931
2145
  ReactEcs2.createElement(Label2, { value: "LIVE", fontSize: this.s(10), color: THEME.colors.white })
1932
2146
  ]
1933
2147
  })
2148
+ ] : [],
2149
+ // A locked channel (2026-11-20): its badge, the words a refused pick shows - one line, 12px in the 260px card
2150
+ ...video.locked === true ? [
2151
+ ReactEcs2.createElement(UiEntity2, {
2152
+ key: "locked",
2153
+ uiTransform: { height: this.s(16), marginTop: 4 },
2154
+ uiText: { value: LOCKED_LINE, fontSize: this.s(12), color: THEME.colors.yellow }
2155
+ })
1934
2156
  ] : []
1935
2157
  ]
1936
2158
  }),
@@ -2097,7 +2319,7 @@ var GuideUIModule = class {
2097
2319
  // src/ui/chat-ui.tsx
2098
2320
  import ReactEcs3, { UiEntity as UiEntity3, Label as Label3, Input as Input3, Button as Button2 } from "@dcl/sdk/react-ecs";
2099
2321
  import { Color4 as Color44 } from "@dcl/sdk/math";
2100
- import { signedFetch as signedFetch2 } from "~system/SignedFetch";
2322
+ import { signedFetch as signedFetch3 } from "~system/SignedFetch";
2101
2323
  import { getPlayer } from "@dcl/sdk/players";
2102
2324
  import { openExternalUrl as openExternalUrl3 } from "~system/RestrictedActions";
2103
2325
  var POLL_INTERVAL_ACTIVE = 5e3;
@@ -2284,7 +2506,7 @@ var ChatUIModule = class {
2284
2506
  this.isSigningIn = true;
2285
2507
  try {
2286
2508
  const baseUrl = this.getBaseUrl();
2287
- const response = await signedFetch2({
2509
+ const response = await signedFetch3({
2288
2510
  url: `${baseUrl}/api/auth/dcl`,
2289
2511
  init: {
2290
2512
  method: "POST",
@@ -2386,7 +2608,7 @@ var ChatUIModule = class {
2386
2608
  this.inputText = "";
2387
2609
  try {
2388
2610
  const baseUrl = this.getBaseUrl();
2389
- const response = await signedFetch2({
2611
+ const response = await signedFetch3({
2390
2612
  url: `${baseUrl}/api/chat/send`,
2391
2613
  init: {
2392
2614
  method: "POST",
@@ -2936,7 +3158,6 @@ import ReactEcs6, { UiEntity as UiEntity6, Button as Button4, Label as Label6, I
2936
3158
  import { Color4 as Color46 } from "@dcl/sdk/math";
2937
3159
  import { getPlayer as getPlayer2 } from "@dcl/sdk/players";
2938
3160
  import { openExternalUrl as openExternalUrl5 } from "~system/RestrictedActions";
2939
- import { signedFetch as signedFetch3 } from "~system/SignedFetch";
2940
3161
 
2941
3162
  // src/ui/ui-renderer.tsx
2942
3163
  import ReactEcs4, { ReactEcsRenderer, UiEntity as UiEntity4, Label as Label4 } from "@dcl/sdk/react-ecs";
@@ -3136,6 +3357,25 @@ function BlockedNotice(props) {
3136
3357
  );
3137
3358
  }
3138
3359
 
3360
+ // src/ui/trial-text.ts
3361
+ function trialHours(trialSparks) {
3362
+ if (typeof trialSparks !== "number" || !Number.isFinite(trialSparks) || trialSparks <= 0) return null;
3363
+ return Math.round(trialSparks / 60 * 10) / 10;
3364
+ }
3365
+ var hoursWord = (h) => h === 1 ? "hour" : "hours";
3366
+ function trialButtonText(trialSparks) {
3367
+ const h = trialHours(trialSparks);
3368
+ return h === null ? "Start Free Trial" : `Start Free ${h}-Hour Trial`;
3369
+ }
3370
+ function trialNoteText(trialSparks) {
3371
+ const h = trialHours(trialSparks);
3372
+ return h === null ? "One-time streaming trial" : `One-time trial \u2022 ${h} ${hoursWord(h)} of streaming`;
3373
+ }
3374
+ function trialActivatedText(hoursGranted) {
3375
+ const h = typeof hoursGranted === "number" && Number.isFinite(hoursGranted) && hoursGranted > 0 ? hoursGranted : null;
3376
+ return h === null ? "Streaming trial activated!" : `${h}-hour streaming trial activated!`;
3377
+ }
3378
+
3139
3379
  // src/utils/player-wait.ts
3140
3380
  var PLAYER_WAIT_STEP_MS = 1e3;
3141
3381
  var PLAYER_WAIT_MAX_MS = 30 * 1e3;
@@ -3455,6 +3695,7 @@ var ModerationModule = class {
3455
3695
  };
3456
3696
 
3457
3697
  // src/ui/admin-panel-ui.tsx
3698
+ var VIDEO_PLAY_TYPES = /* @__PURE__ */ new Set(["videoPlay", "videoSetUrl", "videoPlaySlot"]);
3458
3699
  var FIGURE_NAMES = ["recordings", "vaulted", "slugKeyedLeft", "pendingReports"];
3459
3700
  function figuresOf(value) {
3460
3701
  const figures = value?.figures;
@@ -3554,6 +3795,11 @@ var AdminPanelUIModule = class {
3554
3795
  this.broadcastStatus = "";
3555
3796
  /** 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 */
3556
3797
  this.currentVideoUrl = null;
3798
+ /**
3799
+ * The locked channel the screen last played (2026-11-20), in place of a url: PLAYBACK Play queues it again as
3800
+ * `{ channel, locked: true }` - a locked channel's link is this visitor's own and never goes into the queue
3801
+ */
3802
+ this.currentLockedChannel = null;
3557
3803
  // Scene controls (2026-11-18): the scene's own declaration, each control's current option on this copy, the tab's
3558
3804
  // status line, and the once-a-load gates for the declaration's upload and the saved state's read
3559
3805
  this.controls = [];
@@ -3632,12 +3878,12 @@ var AdminPanelUIModule = class {
3632
3878
  {
3633
3879
  uiTransform: { width: this.s(200), height: this.s(UI_DIMENSIONS.admin.buttonHeight), margin: { bottom: 6 } },
3634
3880
  uiBackground: { color: this.trialClaiming ? C2.btn : C2.green },
3635
- value: this.trialClaiming ? "Claiming..." : "Start Free 4-Hour Trial",
3881
+ value: this.trialClaiming ? "Claiming..." : trialButtonText(this.streamData?.trialSparks),
3636
3882
  fontSize: t.button,
3637
3883
  color: C2.text,
3638
3884
  onMouseDown: () => this.claimTrial()
3639
3885
  }
3640
- ), this.trialClaimError && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.trialClaimError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "One-time trial \u2022 4 hours of streaming", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })), !this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column" } }, /* @__PURE__ */ ReactEcs6.createElement(
3886
+ ), this.trialClaimError && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.trialClaimError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: trialNoteText(this.streamData?.trialSparks), fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })), !this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column" } }, /* @__PURE__ */ ReactEcs6.createElement(
3641
3887
  Button4,
3642
3888
  {
3643
3889
  uiTransform: { width: this.s(170), height: this.s(UI_DIMENSIONS.admin.buttonHeight), margin: { bottom: 6 } },
@@ -3681,9 +3927,9 @@ var AdminPanelUIModule = class {
3681
3927
  )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "HLS Playback:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs6.createElement(
3682
3928
  Label6,
3683
3929
  {
3684
- value: this.streamData.hlsUrl || "Not available",
3930
+ value: this.streamData.locked === true ? LOCKED_LINE : this.streamData.hlsUrl || "Not available",
3685
3931
  fontSize: t.label,
3686
- color: this.streamData.hlsUrl ? C2.green : C2.textDim,
3932
+ color: this.streamData.locked === true ? C2.yellow : this.streamData.hlsUrl ? C2.green : C2.textDim,
3687
3933
  uiTransform: { margin: { left: 6 } }
3688
3934
  }
3689
3935
  )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, !this.streamData.isLive && /* @__PURE__ */ ReactEcs6.createElement(
@@ -3706,7 +3952,7 @@ var AdminPanelUIModule = class {
3706
3952
  color: C2.text,
3707
3953
  onMouseDown: () => this.stopStream()
3708
3954
  }
3709
- ), this.streamData.isLive && this.streamData.hlsUrl && /* @__PURE__ */ ReactEcs6.createElement(
3955
+ ), this.streamData.isLive && (this.streamData.hlsUrl || this.streamData.locked === true) && /* @__PURE__ */ ReactEcs6.createElement(
3710
3956
  Button4,
3711
3957
  {
3712
3958
  uiTransform: { width: this.s(100), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
@@ -3714,7 +3960,7 @@ var AdminPanelUIModule = class {
3714
3960
  value: "Play on Screen",
3715
3961
  fontSize: t.buttonSmall,
3716
3962
  color: C2.text,
3717
- onMouseDown: () => this.playStreamOnScreen(this.streamData.hlsUrl)
3963
+ onMouseDown: () => this.playStreamOnScreen()
3718
3964
  }
3719
3965
  )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3720
3966
  Button4,
@@ -3807,7 +4053,7 @@ var AdminPanelUIModule = class {
3807
4053
  {
3808
4054
  value: this.videoStatus,
3809
4055
  fontSize: t.status,
3810
- color: this.videoStatus.startsWith("Not sent") ? C2.red : C2.green,
4056
+ color: this.videoStatus.startsWith("Not sent") || this.videoStatus === LOCKED_LINE || this.videoStatus === UNAVAILABLE_LINE ? C2.red : C2.green,
3811
4057
  uiTransform: { height: this.s(18), margin: { bottom: 6 } }
3812
4058
  }
3813
4059
  ), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "PLAYBACK", color: C2.green }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
@@ -4350,8 +4596,37 @@ var AdminPanelUIModule = class {
4350
4596
  playUrl(url) {
4351
4597
  if (this.moderation.blocked) return;
4352
4598
  this.currentVideoUrl = url;
4599
+ this.currentLockedChannel = null;
4353
4600
  this.config.onVideoPlay?.(url);
4354
4601
  }
4602
+ /**
4603
+ * A locked channel's play (thestatic.tv's stream lock, 2026-11-20): a queued video command carrying
4604
+ * `{ channel, locked: true }`, the owner's Play on Screen for a locked stream, a locked slot. This copy asks
4605
+ * thestatic.tv's door for the link, signed as this visitor (the client's stream link: one request in flight per
4606
+ * channel, the re-ask before it expires), and plays it through onVideoPlay only when admitted. A refusal plays
4607
+ * nothing; the notice and this tab's video line say LOCKED: TheStatic.tv citizens. A blocked visitor asks nothing.
4608
+ * The link itself is never kept for PLAYBACK Play or sent to the queue - the channel is.
4609
+ */
4610
+ playLocked(channel) {
4611
+ if (this.moderation.blocked) return;
4612
+ const slug = channelOf(channel);
4613
+ if (!slug) {
4614
+ this.log("A locked play names no channel - nothing plays");
4615
+ return;
4616
+ }
4617
+ this.currentLockedChannel = slug;
4618
+ this.currentVideoUrl = null;
4619
+ this.client._playLockedChannel?.(slug, {
4620
+ deliver: (url) => {
4621
+ if (this.moderation.blocked) return;
4622
+ this.config.onVideoPlay?.(url);
4623
+ },
4624
+ stop: () => this.config.onVideoStop?.(),
4625
+ failed: (line) => {
4626
+ this.videoStatus = line;
4627
+ }
4628
+ });
4629
+ }
4355
4630
  /**
4356
4631
  * Toggle the admin panel open/closed
4357
4632
  */
@@ -4562,15 +4837,12 @@ var AdminPanelUIModule = class {
4562
4837
  * Every gated admin call is a DCL signed fetch (thestatic.tv STATIC-01, 2026-10-07): the
4563
4838
  * explorer signs it with the player's identity, and the server checks the signature and that it
4564
4839
  * came from the scene deployed at this scene's registered location. A wallet named in a query or
4565
- * body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites.
4840
+ * body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites. The
4841
+ * request itself lives in utils/signed-request.ts since 2026-11-20 (it was here), so the locked
4842
+ * channel's door - which a Standard scene asks too, with no panel - goes through the same one.
4566
4843
  */
4567
4844
  async signedRequest(url, init = {}) {
4568
- const res = await signedFetch3({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
4569
- return {
4570
- ok: res.ok,
4571
- status: res.status,
4572
- json: async () => res.body ? JSON.parse(res.body) : {}
4573
- };
4845
+ return signedRequest(url, init);
4574
4846
  }
4575
4847
  /**
4576
4848
  * 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
@@ -4623,12 +4895,18 @@ var AdminPanelUIModule = class {
4623
4895
  } else if (cmd.type === "privateMode" && this.venue) {
4624
4896
  this.log("Received privateMode - re-reading my standing");
4625
4897
  this.moderation.handleCommand(cmd.type, cmd.payload);
4898
+ } else if (VIDEO_PLAY_TYPES.has(cmd.type) && cmd.payload?.locked === true) {
4899
+ this.log("Received locked play:", cmd.type, cmd.payload.channel);
4900
+ this.playLocked(cmd.payload.channel);
4626
4901
  } else if ((cmd.type === "videoPlay" || cmd.type === "videoSetUrl") && cmd.payload?.url) {
4627
4902
  this.log("Received video play:", cmd.type, cmd.payload.url);
4628
4903
  this.playUrl(cmd.payload.url);
4629
4904
  } else if (cmd.type === "videoStop" || cmd.type === "videoClear") {
4630
4905
  this.log("Received video stop/clear:", cmd.type);
4631
- if (cmd.type === "videoClear") this.currentVideoUrl = null;
4906
+ if (cmd.type === "videoClear") {
4907
+ this.currentVideoUrl = null;
4908
+ this.currentLockedChannel = null;
4909
+ }
4632
4910
  this.config.onVideoStop?.();
4633
4911
  } else if (cmd.type === "videoPlaySlot" && cmd.payload?.slot) {
4634
4912
  const slotId = cmd.payload.slot;
@@ -4692,6 +4970,11 @@ var AdminPanelUIModule = class {
4692
4970
  videoSlots: data.videoSlots || {}
4693
4971
  };
4694
4972
  if (typeof data.currentVideoUrl === "string" && data.currentVideoUrl !== "") this.currentVideoUrl = data.currentVideoUrl;
4973
+ const lockedCurrent = data.currentVideo?.locked === true ? channelOf(data.currentVideo.channel) : null;
4974
+ if (lockedCurrent) {
4975
+ this.currentLockedChannel = lockedCurrent;
4976
+ this.currentVideoUrl = null;
4977
+ }
4695
4978
  this.videoStateFetched = true;
4696
4979
  this.log("Video state fetched:", this.videoState.defaultSlot || "no default");
4697
4980
  }
@@ -4704,6 +4987,11 @@ var AdminPanelUIModule = class {
4704
4987
  */
4705
4988
  playSlot(slotId) {
4706
4989
  const slot = this.videoState?.videoSlots?.[slotId];
4990
+ if (slot?.locked === true) {
4991
+ this.log("Playing locked slot:", slotId);
4992
+ this.playLocked(slot.slug ?? slot.channel);
4993
+ return;
4994
+ }
4707
4995
  if (slot?.url) {
4708
4996
  this.log("Playing slot:", slotId, slot.url);
4709
4997
  this.playUrl(slot.url);
@@ -4719,7 +5007,10 @@ var AdminPanelUIModule = class {
4719
5007
  if (!this.videoState?.defaultSlot) return;
4720
5008
  const defaultSlot = this.videoState.defaultSlot;
4721
5009
  const slot = this.videoState.videoSlots?.[defaultSlot];
4722
- if (slot?.url) {
5010
+ if (slot?.locked === true) {
5011
+ this.log("Auto-playing locked default slot:", defaultSlot);
5012
+ this.playLocked(slot.slug ?? slot.channel);
5013
+ } else if (slot?.url) {
4723
5014
  this.log("Auto-playing default slot:", defaultSlot);
4724
5015
  this.playUrl(slot.url);
4725
5016
  }
@@ -4773,7 +5064,7 @@ var AdminPanelUIModule = class {
4773
5064
  this.log("Trial claimed:", data.channel);
4774
5065
  this.streamFetched = false;
4775
5066
  await this.fetchStreamData();
4776
- this.config.onBroadcast?.(`4-hour streaming trial activated!`);
5067
+ this.config.onBroadcast?.(trialActivatedText(data.trial?.hoursGranted));
4777
5068
  } else {
4778
5069
  this.trialClaimError = data.error || "Failed to claim trial";
4779
5070
  this.log("Trial claim failed:", data.error);
@@ -5199,8 +5490,25 @@ var AdminPanelUIModule = class {
5199
5490
  this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5200
5491
  });
5201
5492
  }
5202
- /** Play on Screen: the scene's own live stream, as PLAY NOW with its HLS url (what the scene's page sends for it) */
5203
- playStreamOnScreen(url) {
5493
+ /**
5494
+ * 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
5495
+ * locked stream (2026-11-20: the /stream answer says locked, with its slug and no hlsUrl) plays here through the
5496
+ * link asked for signed as the owner, and queues `videoSetUrl { channel, locked: true }` - never a url, so every
5497
+ * visitor's copy asks for its own link and only the admitted play it.
5498
+ */
5499
+ playStreamOnScreen() {
5500
+ const data = this.streamData;
5501
+ if (!data) return;
5502
+ if (data.locked === true) {
5503
+ const channel = channelOf(data.slug ?? data.channelId);
5504
+ if (!channel) return;
5505
+ this.playLocked(channel);
5506
+ this.sendSceneCommand("videoSetUrl", { channel, locked: true }, this.videoLine).catch(() => {
5507
+ });
5508
+ return;
5509
+ }
5510
+ const url = data.hlsUrl;
5511
+ if (!url) return;
5204
5512
  this.playUrl(url);
5205
5513
  this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5206
5514
  });
@@ -5218,6 +5526,13 @@ var AdminPanelUIModule = class {
5218
5526
  */
5219
5527
  playbackPlay() {
5220
5528
  this.config.onCommand?.("videoPlay", { playing: true });
5529
+ const locked = this.currentLockedChannel;
5530
+ if (locked) {
5531
+ this.playLocked(locked);
5532
+ this.sendSceneCommand("videoPlay", { channel: locked, locked: true }, this.videoLine).catch(() => {
5533
+ });
5534
+ return;
5535
+ }
5221
5536
  const url = this.currentVideoUrl;
5222
5537
  if (!url) {
5223
5538
  this.videoStatus = "Not sent: no video";
@@ -5241,6 +5556,7 @@ var AdminPanelUIModule = class {
5241
5556
  resetDefault() {
5242
5557
  this.config.onCommand?.("videoClear", {});
5243
5558
  this.currentVideoUrl = null;
5559
+ this.currentLockedChannel = null;
5244
5560
  this.config.onVideoStop?.();
5245
5561
  this.sendSceneCommand("videoClear", {}, this.videoLine).catch(() => {
5246
5562
  });
@@ -5442,6 +5758,18 @@ var StaticTVClient = class {
5442
5758
  this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
5443
5759
  this.frames = new FramesModule(this);
5444
5760
  if (config.frames) this.frames.register(config.frames);
5761
+ this.streamLink = new StreamLinkModule({
5762
+ doorUrl: () => {
5763
+ const sceneId = this.getSceneId();
5764
+ return sceneId ? `${this.apiUrl}/scene/${encodeURIComponent(sceneId)}/stream/play` : null;
5765
+ },
5766
+ post: (url, body) => signedRequest(url, { method: "POST", headers: { "Content-Type": "application/json" }, body }),
5767
+ blocked: () => this.isVisitorBlocked,
5768
+ notify: (line) => this.showNotification(line),
5769
+ setInterval: dclSetInterval,
5770
+ clearInterval: dclClearInterval,
5771
+ log: (msg, ...args) => this.log(msg, ...args)
5772
+ });
5445
5773
  if (!config.apiKey) {
5446
5774
  this._disabled = true;
5447
5775
  this._keyType = null;
@@ -5633,6 +5961,7 @@ var StaticTVClient = class {
5633
5961
  */
5634
5962
  playVideo(url) {
5635
5963
  if (this.isVisitorBlocked) return;
5964
+ this.streamLink.playChanged(url);
5636
5965
  const screen = this.config.videoScreen;
5637
5966
  if (screen !== void 0) {
5638
5967
  this.log(`Playing video: ${url}`);
@@ -5657,6 +5986,7 @@ var StaticTVClient = class {
5657
5986
  */
5658
5987
  stopVideo() {
5659
5988
  const screen = this.config.videoScreen;
5989
+ this.streamLink.cancel();
5660
5990
  this._pendingVideoData = null;
5661
5991
  this._streamVerified = false;
5662
5992
  this._clearVerificationTimeout();
@@ -5815,10 +6145,48 @@ var StaticTVClient = class {
5815
6145
  _handleGuideVideoSelect(video) {
5816
6146
  if (!video.src) return;
5817
6147
  if (this.isVisitorBlocked) return;
6148
+ this.streamLink.cancel();
6149
+ this._playGuideEntry(video);
6150
+ }
6151
+ /**
6152
+ * A guide entry with its url, onto the SDK's player and/or onVideoPlay, with the stream verification - an unlocked
6153
+ * pick's, and a locked one's once its link is in hand (2026-11-20; until then this was _handleGuideVideoSelect's body)
6154
+ * @internal
6155
+ */
6156
+ _playGuideEntry(video) {
5818
6157
  this._pendingVideoData = video;
5819
6158
  const isLiveStream = video.channelId !== void 0 || video.src.includes(".m3u8") || video.src.includes("media.thestatic.tv");
5820
6159
  this._playVideoWithVerification(video, isLiveStream);
5821
6160
  }
6161
+ /**
6162
+ * A locked channel's guide entry picked (thestatic.tv's stream lock, 2026-11-20). It carries no url: the SDK asks
6163
+ * thestatic.tv's door for the link, signed as this visitor, and only with a link in hand does the entry go on - to
6164
+ * the SDK's player and onVideoPlay as an unlocked pick does, and to the scene's own guideUI.onVideoSelect - with the
6165
+ * link as its src. Scenes' own handlers play `video.src` (TheStatic.tv HQ's, the templates'), so handing them the
6166
+ * entry before the answer would play an empty src, and on a refusal play what should not play: a refusal hands
6167
+ * nobody anything and shows LOCKED: TheStatic.tv citizens. Each fresh link before the old one expires goes the same
6168
+ * way (the re-ask); a re-ask refused stops the video. A blocked visitor asks nothing.
6169
+ * @internal
6170
+ */
6171
+ _selectLockedGuideEntry(video) {
6172
+ if (this.isVisitorBlocked) return;
6173
+ this.streamLink.play(video.channel, {
6174
+ deliver: (url) => {
6175
+ const entry = { ...video, src: url };
6176
+ if (this.config.videoScreen !== void 0 || this.config.onVideoPlay) this._playGuideEntry(entry);
6177
+ if (this.config.guideUI?.onVideoSelect) this.config.guideUI.onVideoSelect(entry);
6178
+ },
6179
+ stop: () => this.stopVideo()
6180
+ });
6181
+ }
6182
+ /**
6183
+ * A locked channel's play from the Admin Panel - a queued video command carrying `{ channel, locked: true }`, the
6184
+ * 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.
6185
+ * @internal
6186
+ */
6187
+ _playLockedChannel(channel, handlers) {
6188
+ this.streamLink.play(channel, handlers);
6189
+ }
5822
6190
  /**
5823
6191
  * Play video with stream verification for live content
5824
6192
  * Works with both videoScreen (SDK-managed) and onVideoPlay (user-managed) modes.
@@ -5941,6 +6309,7 @@ var StaticTVClient = class {
5941
6309
  this.guideUI?.hide();
5942
6310
  this.chatUI?.hide();
5943
6311
  this.heartbeat?.stopWatching();
6312
+ this.streamLink.cancel();
5944
6313
  this._pendingVideoData = null;
5945
6314
  this._clearVerificationTimeout();
5946
6315
  if (screen !== void 0 && VideoPlayer.has(screen)) {
@@ -5982,6 +6351,10 @@ var StaticTVClient = class {
5982
6351
  const guideConfig = {
5983
6352
  ...this.config.guideUI,
5984
6353
  onVideoSelect: (video) => {
6354
+ if (video.locked === true) {
6355
+ this._selectLockedGuideEntry(video);
6356
+ return;
6357
+ }
5985
6358
  if (this.config.videoScreen !== void 0 || this.config.onVideoPlay) {
5986
6359
  this._handleGuideVideoSelect(video);
5987
6360
  }
@@ -6297,6 +6670,7 @@ var StaticTVClient = class {
6297
6670
  this.log("StaticTVClient destroyed (was disabled)");
6298
6671
  return;
6299
6672
  }
6673
+ this.streamLink.cancel();
6300
6674
  if (this.heartbeat) {
6301
6675
  this.heartbeat.stopWatching();
6302
6676
  }