tokwatchr 0.6.3 → 0.6.5
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 +4 -10
- package/package.json +1 -1
- package/src/TikTokLiveDownloader.ts +11 -8
package/dist/index.mjs
CHANGED
|
@@ -721,17 +721,9 @@ var TikTokLiveDownloader = class {
|
|
|
721
721
|
this.setState("stopping");
|
|
722
722
|
this.abortController.abort();
|
|
723
723
|
await new Promise((resolve) => {
|
|
724
|
-
let settled = false;
|
|
725
|
-
const timer = setTimeout(() => {
|
|
726
|
-
settled = true;
|
|
727
|
-
resolve();
|
|
728
|
-
}, 5e3);
|
|
729
724
|
const check = () => {
|
|
730
|
-
if (
|
|
731
|
-
|
|
732
|
-
clearTimeout(timer);
|
|
733
|
-
resolve();
|
|
734
|
-
} else setTimeout(check, 100);
|
|
725
|
+
if (this._state === "done") resolve();
|
|
726
|
+
else setTimeout(check, 100);
|
|
735
727
|
};
|
|
736
728
|
check();
|
|
737
729
|
});
|
|
@@ -766,6 +758,8 @@ var TikTokLiveDownloader = class {
|
|
|
766
758
|
return resolved;
|
|
767
759
|
}
|
|
768
760
|
async _run(waitForLive) {
|
|
761
|
+
this.abortController = new AbortController();
|
|
762
|
+
if (this.options.signal) this.options.signal.addEventListener("abort", () => this.abortController.abort(), { once: true });
|
|
769
763
|
const pendingRemuxes = [];
|
|
770
764
|
try {
|
|
771
765
|
this.setState("waiting");
|
package/package.json
CHANGED
|
@@ -178,17 +178,10 @@ export class TikTokLiveDownloader {
|
|
|
178
178
|
}
|
|
179
179
|
this.setState("stopping");
|
|
180
180
|
this.abortController.abort();
|
|
181
|
-
// Wait for
|
|
181
|
+
// Wait for _run()'s catch block to finish remux and set "done"
|
|
182
182
|
await new Promise<void>((resolve) => {
|
|
183
|
-
let settled = false;
|
|
184
|
-
const timer = setTimeout(() => {
|
|
185
|
-
settled = true;
|
|
186
|
-
resolve();
|
|
187
|
-
}, 5_000);
|
|
188
183
|
const check = () => {
|
|
189
|
-
if (settled) return;
|
|
190
184
|
if (this._state === "done") {
|
|
191
|
-
clearTimeout(timer);
|
|
192
185
|
resolve();
|
|
193
186
|
} else {
|
|
194
187
|
setTimeout(check, 100);
|
|
@@ -244,6 +237,16 @@ export class TikTokLiveDownloader {
|
|
|
244
237
|
}
|
|
245
238
|
|
|
246
239
|
private async _run(waitForLive: boolean): Promise<DownloadResult> {
|
|
240
|
+
// Reset abortController so start() can be called multiple times
|
|
241
|
+
this.abortController = new AbortController();
|
|
242
|
+
if (this.options.signal) {
|
|
243
|
+
this.options.signal.addEventListener(
|
|
244
|
+
"abort",
|
|
245
|
+
() => this.abortController.abort(),
|
|
246
|
+
{ once: true },
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
247
250
|
// Track background remuxes so we can await them on error/abort
|
|
248
251
|
const pendingRemuxes: Promise<DownloadResult>[] = [];
|
|
249
252
|
|