@tiktool/live 2.12.1 → 2.12.2

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
@@ -9,9 +9,9 @@ var __commonJS = (cb, mod) => function __require2() {
9
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
10
  };
11
11
 
12
- // ../../../node_modules/ms/index.js
12
+ // node_modules/ms/index.js
13
13
  var require_ms = __commonJS({
14
- "../../../node_modules/ms/index.js"(exports, module) {
14
+ "node_modules/ms/index.js"(exports, module) {
15
15
  "use strict";
16
16
  var s = 1e3;
17
17
  var m = s * 60;
@@ -126,9 +126,9 @@ var require_ms = __commonJS({
126
126
  }
127
127
  });
128
128
 
129
- // ../../../node_modules/debug/src/common.js
129
+ // node_modules/debug/src/common.js
130
130
  var require_common = __commonJS({
131
- "../../../node_modules/debug/src/common.js"(exports, module) {
131
+ "node_modules/debug/src/common.js"(exports, module) {
132
132
  "use strict";
133
133
  function setup(env) {
134
134
  createDebug.debug = createDebug;
@@ -304,9 +304,9 @@ var require_common = __commonJS({
304
304
  }
305
305
  });
306
306
 
307
- // ../../../node_modules/debug/src/browser.js
307
+ // node_modules/debug/src/browser.js
308
308
  var require_browser = __commonJS({
309
- "../../../node_modules/debug/src/browser.js"(exports, module) {
309
+ "node_modules/debug/src/browser.js"(exports, module) {
310
310
  "use strict";
311
311
  exports.formatArgs = formatArgs;
312
312
  exports.save = save;
@@ -475,124 +475,9 @@ var require_browser = __commonJS({
475
475
  }
476
476
  });
477
477
 
478
- // ../../../../node_modules/has-flag/index.js
479
- var require_has_flag = __commonJS({
480
- "../../../../node_modules/has-flag/index.js"(exports, module) {
481
- "use strict";
482
- module.exports = (flag, argv = process.argv) => {
483
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
484
- const position = argv.indexOf(prefix + flag);
485
- const terminatorPosition = argv.indexOf("--");
486
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
487
- };
488
- }
489
- });
490
-
491
- // ../../../../node_modules/supports-color/index.js
492
- var require_supports_color = __commonJS({
493
- "../../../../node_modules/supports-color/index.js"(exports, module) {
494
- "use strict";
495
- var os = __require("os");
496
- var tty = __require("tty");
497
- var hasFlag = require_has_flag();
498
- var { env } = process;
499
- var forceColor;
500
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
501
- forceColor = 0;
502
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
503
- forceColor = 1;
504
- }
505
- if ("FORCE_COLOR" in env) {
506
- if (env.FORCE_COLOR === "true") {
507
- forceColor = 1;
508
- } else if (env.FORCE_COLOR === "false") {
509
- forceColor = 0;
510
- } else {
511
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
512
- }
513
- }
514
- function translateLevel(level) {
515
- if (level === 0) {
516
- return false;
517
- }
518
- return {
519
- level,
520
- hasBasic: true,
521
- has256: level >= 2,
522
- has16m: level >= 3
523
- };
524
- }
525
- function supportsColor(haveStream, streamIsTTY) {
526
- if (forceColor === 0) {
527
- return 0;
528
- }
529
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
530
- return 3;
531
- }
532
- if (hasFlag("color=256")) {
533
- return 2;
534
- }
535
- if (haveStream && !streamIsTTY && forceColor === void 0) {
536
- return 0;
537
- }
538
- const min = forceColor || 0;
539
- if (env.TERM === "dumb") {
540
- return min;
541
- }
542
- if (process.platform === "win32") {
543
- const osRelease = os.release().split(".");
544
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
545
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
546
- }
547
- return 1;
548
- }
549
- if ("CI" in env) {
550
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
551
- return 1;
552
- }
553
- return min;
554
- }
555
- if ("TEAMCITY_VERSION" in env) {
556
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
557
- }
558
- if (env.COLORTERM === "truecolor") {
559
- return 3;
560
- }
561
- if ("TERM_PROGRAM" in env) {
562
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
563
- switch (env.TERM_PROGRAM) {
564
- case "iTerm.app":
565
- return version >= 3 ? 3 : 2;
566
- case "Apple_Terminal":
567
- return 2;
568
- }
569
- }
570
- if (/-256(color)?$/i.test(env.TERM)) {
571
- return 2;
572
- }
573
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
574
- return 1;
575
- }
576
- if ("COLORTERM" in env) {
577
- return 1;
578
- }
579
- return min;
580
- }
581
- function getSupportLevel(stream) {
582
- const level = supportsColor(stream, stream && stream.isTTY);
583
- return translateLevel(level);
584
- }
585
- module.exports = {
586
- supportsColor: getSupportLevel,
587
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
588
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
589
- };
590
- }
591
- });
592
-
593
- // ../../../node_modules/debug/src/node.js
478
+ // node_modules/debug/src/node.js
594
479
  var require_node = __commonJS({
595
- "../../../node_modules/debug/src/node.js"(exports, module) {
480
+ "node_modules/debug/src/node.js"(exports, module) {
596
481
  "use strict";
597
482
  var tty = __require("tty");
598
483
  var util = __require("util");
@@ -609,7 +494,7 @@ var require_node = __commonJS({
609
494
  );
610
495
  exports.colors = [6, 2, 3, 4, 5, 1];
611
496
  try {
612
- const supportsColor = require_supports_color();
497
+ const supportsColor = __require("supports-color");
613
498
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
614
499
  exports.colors = [
615
500
  20,
@@ -765,9 +650,9 @@ var require_node = __commonJS({
765
650
  }
766
651
  });
767
652
 
768
- // ../../../node_modules/debug/src/index.js
653
+ // node_modules/debug/src/index.js
769
654
  var require_src = __commonJS({
770
- "../../../node_modules/debug/src/index.js"(exports, module) {
655
+ "node_modules/debug/src/index.js"(exports, module) {
771
656
  "use strict";
772
657
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
773
658
  module.exports = require_browser();
@@ -777,9 +662,9 @@ var require_src = __commonJS({
777
662
  }
778
663
  });
779
664
 
780
- // ../../../node_modules/agent-base/dist/helpers.js
665
+ // node_modules/agent-base/dist/helpers.js
781
666
  var require_helpers = __commonJS({
782
- "../../../node_modules/agent-base/dist/helpers.js"(exports) {
667
+ "node_modules/agent-base/dist/helpers.js"(exports) {
783
668
  "use strict";
784
669
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
785
670
  if (k2 === void 0) k2 = k;
@@ -847,9 +732,9 @@ var require_helpers = __commonJS({
847
732
  }
848
733
  });
849
734
 
850
- // ../../../node_modules/agent-base/dist/index.js
735
+ // node_modules/agent-base/dist/index.js
851
736
  var require_dist = __commonJS({
852
- "../../../node_modules/agent-base/dist/index.js"(exports) {
737
+ "node_modules/agent-base/dist/index.js"(exports) {
853
738
  "use strict";
854
739
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
855
740
  if (k2 === void 0) k2 = k;
@@ -1003,9 +888,9 @@ var require_dist = __commonJS({
1003
888
  }
1004
889
  });
1005
890
 
1006
- // ../../../node_modules/https-proxy-agent/dist/parse-proxy-response.js
891
+ // node_modules/https-proxy-agent/dist/parse-proxy-response.js
1007
892
  var require_parse_proxy_response = __commonJS({
1008
- "../../../node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports) {
893
+ "node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports) {
1009
894
  "use strict";
1010
895
  var __importDefault = exports && exports.__importDefault || function(mod) {
1011
896
  return mod && mod.__esModule ? mod : { "default": mod };
@@ -1099,9 +984,9 @@ var require_parse_proxy_response = __commonJS({
1099
984
  }
1100
985
  });
1101
986
 
1102
- // ../../../node_modules/https-proxy-agent/dist/index.js
987
+ // node_modules/https-proxy-agent/dist/index.js
1103
988
  var require_dist2 = __commonJS({
1104
- "../../../node_modules/https-proxy-agent/dist/index.js"(exports) {
989
+ "node_modules/https-proxy-agent/dist/index.js"(exports) {
1105
990
  "use strict";
1106
991
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
1107
992
  if (k2 === void 0) k2 = k;
@@ -2209,6 +2094,7 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
2209
2094
  }
2210
2095
  } else {
2211
2096
  console.log(`[TikTokLive] No presets for @${this.uniqueId}. Resolving via sign server (${this.signServerUrl})...`);
2097
+ let confirmedOffline = false;
2212
2098
  try {
2213
2099
  const roomResp = await fetch(`${this.signServerUrl}/webcast/room_id`, {
2214
2100
  method: "POST",
@@ -2218,7 +2104,10 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
2218
2104
  console.log(`[TikTokLive] room_id response: ${roomResp.status}`);
2219
2105
  if (roomResp.ok) {
2220
2106
  const roomData = await roomResp.json();
2221
- if (roomData.status_code === 0 && roomData.data?.room_id) {
2107
+ if (roomData.status_code === 0 && roomData.data?.room_id && roomData.data.alive === false) {
2108
+ confirmedOffline = true;
2109
+ console.log(`[TikTokLive] @${this.uniqueId} resolved to ended room ${roomData.data.room_id} (alive:false)`);
2110
+ } else if (roomData.status_code === 0 && roomData.data?.room_id) {
2222
2111
  roomId = roomData.data.room_id;
2223
2112
  console.log(`[TikTokLive] \xE2\u0153\u2026 Got roomId from sign server: ${roomId}`);
2224
2113
  } else {
@@ -2228,6 +2117,7 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
2228
2117
  } catch (e) {
2229
2118
  console.log(`[TikTokLive] \xE2\x9D\u0152 room_id request failed: ${e.message}`);
2230
2119
  }
2120
+ if (confirmedOffline) throw new Error(`User @${this.uniqueId} is not currently live`);
2231
2121
  if (roomId) {
2232
2122
  try {
2233
2123
  const credResp = await fetch(`${this.signServerUrl}/webcast/ws_credentials`, {