@scarlett-player/hls 1.9.0 → 1.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/{chunk-EP22IZ63.js → chunk-NVPSLRJY.js} +15 -13
- package/dist/index.cjs +30 -36
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -9
- package/dist/light.cjs +30 -36
- package/dist/light.d.cts +3 -3
- package/dist/light.d.ts +3 -3
- package/dist/light.js +1 -9
- package/dist/{sanitize-url-BvhRz6uj.d.cts → types-DnvcTuSn.d.cts} +1 -26
- package/dist/{sanitize-url-BvhRz6uj.d.ts → types-DnvcTuSn.d.ts} +1 -26
- package/package.json +2 -2
|
@@ -5,15 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/sanitize-url.ts
|
|
8
|
-
|
|
9
|
-
if (!url) return void 0;
|
|
10
|
-
try {
|
|
11
|
-
const parsed = new URL(url);
|
|
12
|
-
return `${parsed.origin}${parsed.pathname}`;
|
|
13
|
-
} catch {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
8
|
+
import { sanitizeUrl } from "@scarlett-player/core";
|
|
17
9
|
|
|
18
10
|
// src/create-hls-plugin.ts
|
|
19
11
|
import { ErrorCode } from "@scarlett-player/core";
|
|
@@ -98,11 +90,19 @@ function mapErrorType(hlsType) {
|
|
|
98
90
|
}
|
|
99
91
|
}
|
|
100
92
|
function parseHlsError(data) {
|
|
93
|
+
const frag = data.frag;
|
|
94
|
+
const response = data.response;
|
|
95
|
+
const context = data.context;
|
|
101
96
|
return {
|
|
102
97
|
type: mapErrorType(data.type),
|
|
103
98
|
details: data.details || "Unknown error",
|
|
104
99
|
fatal: data.fatal || false,
|
|
105
|
-
|
|
100
|
+
// hls.js puts the request URL in a different place per error type:
|
|
101
|
+
// playlist errors set data.url, while fragment and key load errors set
|
|
102
|
+
// data.url not at all and carry it on data.frag.url and data.response.url.
|
|
103
|
+
// Reading only data.url dropped the failing segment from every diagnostic
|
|
104
|
+
// an origin outage produces - which is the case the diagnostics exist for.
|
|
105
|
+
url: data.url ?? frag?.url ?? response?.url ?? context?.url,
|
|
106
106
|
reason: data.reason,
|
|
107
107
|
response: data.response
|
|
108
108
|
};
|
|
@@ -232,14 +232,16 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
232
232
|
api.logger.error(`HLS fatal error: ${error.details} (type=${error.type})`, {
|
|
233
233
|
type: error.type,
|
|
234
234
|
details: error.details,
|
|
235
|
-
|
|
235
|
+
status: error.response?.code,
|
|
236
|
+
url: sanitizeUrl(error.url)
|
|
236
237
|
});
|
|
237
238
|
} else {
|
|
238
239
|
api.logger.warn(`HLS error: ${error.details} (type=${error.type}, fatal=${error.fatal})`, {
|
|
239
240
|
type: error.type,
|
|
240
241
|
details: error.details,
|
|
241
242
|
fatal: error.fatal,
|
|
242
|
-
|
|
243
|
+
status: error.response?.code,
|
|
244
|
+
url: sanitizeUrl(error.url)
|
|
243
245
|
});
|
|
244
246
|
}
|
|
245
247
|
callbacks.onError?.(error);
|
|
@@ -446,7 +448,7 @@ function createValidatingPlaylistLoader(Hls) {
|
|
|
446
448
|
}
|
|
447
449
|
|
|
448
450
|
// src/version.ts
|
|
449
|
-
var PKG_VERSION = true ? "1.
|
|
451
|
+
var PKG_VERSION = true ? "1.11.0" : "0.0.0-dev";
|
|
450
452
|
|
|
451
453
|
// src/create-hls-plugin.ts
|
|
452
454
|
var DEFAULT_CONFIG = {
|
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
createHLSPlugin: () => createHLSPlugin,
|
|
34
34
|
default: () => index_default,
|
|
35
|
-
sanitizeUrl: () => sanitizeUrl
|
|
35
|
+
sanitizeUrl: () => import_core.sanitizeUrl
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
38
|
|
|
@@ -45,7 +45,6 @@ __export(hls_loader_exports, {
|
|
|
45
45
|
isHlsJsSupported: () => isHlsJsSupported,
|
|
46
46
|
loadHlsJs: () => loadHlsJs,
|
|
47
47
|
resetLoader: () => resetLoader,
|
|
48
|
-
shouldPreferNativeHLS: () => shouldPreferNativeHLS,
|
|
49
48
|
supportsNativeHLS: () => supportsNativeHLS
|
|
50
49
|
});
|
|
51
50
|
var hlsConstructor = null;
|
|
@@ -55,13 +54,6 @@ function supportsNativeHLS() {
|
|
|
55
54
|
const video = document.createElement("video");
|
|
56
55
|
return video.canPlayType("application/vnd.apple.mpegurl") !== "";
|
|
57
56
|
}
|
|
58
|
-
function shouldPreferNativeHLS() {
|
|
59
|
-
if (!supportsNativeHLS()) return false;
|
|
60
|
-
if (typeof navigator === "undefined") return false;
|
|
61
|
-
const ua = navigator.userAgent;
|
|
62
|
-
const isSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/CriOS/.test(ua);
|
|
63
|
-
return isSafari;
|
|
64
|
-
}
|
|
65
57
|
function isHlsJsSupported() {
|
|
66
58
|
if (hlsConstructor) {
|
|
67
59
|
return hlsConstructor.isSupported();
|
|
@@ -111,7 +103,7 @@ function resetLoader() {
|
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
// src/create-hls-plugin.ts
|
|
114
|
-
var
|
|
106
|
+
var import_core2 = require("@scarlett-player/core");
|
|
115
107
|
|
|
116
108
|
// src/quality.ts
|
|
117
109
|
function formatLevel(level) {
|
|
@@ -172,6 +164,9 @@ function getInitialBandwidthEstimate(overrideBps) {
|
|
|
172
164
|
return HLS_DEFAULT_ESTIMATE;
|
|
173
165
|
}
|
|
174
166
|
|
|
167
|
+
// src/sanitize-url.ts
|
|
168
|
+
var import_core = require("@scarlett-player/core");
|
|
169
|
+
|
|
175
170
|
// src/event-map.ts
|
|
176
171
|
var HLS_ERROR_TYPES = {
|
|
177
172
|
NETWORK_ERROR: "networkError",
|
|
@@ -193,11 +188,19 @@ function mapErrorType(hlsType) {
|
|
|
193
188
|
}
|
|
194
189
|
}
|
|
195
190
|
function parseHlsError(data) {
|
|
191
|
+
const frag = data.frag;
|
|
192
|
+
const response = data.response;
|
|
193
|
+
const context = data.context;
|
|
196
194
|
return {
|
|
197
195
|
type: mapErrorType(data.type),
|
|
198
196
|
details: data.details || "Unknown error",
|
|
199
197
|
fatal: data.fatal || false,
|
|
200
|
-
|
|
198
|
+
// hls.js puts the request URL in a different place per error type:
|
|
199
|
+
// playlist errors set data.url, while fragment and key load errors set
|
|
200
|
+
// data.url not at all and carry it on data.frag.url and data.response.url.
|
|
201
|
+
// Reading only data.url dropped the failing segment from every diagnostic
|
|
202
|
+
// an origin outage produces - which is the case the diagnostics exist for.
|
|
203
|
+
url: data.url ?? frag?.url ?? response?.url ?? context?.url,
|
|
201
204
|
reason: data.reason,
|
|
202
205
|
response: data.response
|
|
203
206
|
};
|
|
@@ -327,14 +330,16 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
327
330
|
api.logger.error(`HLS fatal error: ${error.details} (type=${error.type})`, {
|
|
328
331
|
type: error.type,
|
|
329
332
|
details: error.details,
|
|
330
|
-
|
|
333
|
+
status: error.response?.code,
|
|
334
|
+
url: (0, import_core.sanitizeUrl)(error.url)
|
|
331
335
|
});
|
|
332
336
|
} else {
|
|
333
337
|
api.logger.warn(`HLS error: ${error.details} (type=${error.type}, fatal=${error.fatal})`, {
|
|
334
338
|
type: error.type,
|
|
335
339
|
details: error.details,
|
|
336
340
|
fatal: error.fatal,
|
|
337
|
-
|
|
341
|
+
status: error.response?.code,
|
|
342
|
+
url: (0, import_core.sanitizeUrl)(error.url)
|
|
338
343
|
});
|
|
339
344
|
}
|
|
340
345
|
callbacks.onError?.(error);
|
|
@@ -540,19 +545,8 @@ function createValidatingPlaylistLoader(Hls) {
|
|
|
540
545
|
};
|
|
541
546
|
}
|
|
542
547
|
|
|
543
|
-
// src/sanitize-url.ts
|
|
544
|
-
function sanitizeUrl(url) {
|
|
545
|
-
if (!url) return void 0;
|
|
546
|
-
try {
|
|
547
|
-
const parsed = new URL(url);
|
|
548
|
-
return `${parsed.origin}${parsed.pathname}`;
|
|
549
|
-
} catch {
|
|
550
|
-
return void 0;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
548
|
// src/version.ts
|
|
555
|
-
var PKG_VERSION = true ? "1.
|
|
549
|
+
var PKG_VERSION = true ? "1.11.0" : "0.0.0-dev";
|
|
556
550
|
|
|
557
551
|
// src/create-hls-plugin.ts
|
|
558
552
|
var DEFAULT_CONFIG = {
|
|
@@ -712,22 +706,22 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
712
706
|
];
|
|
713
707
|
const mapFatalErrorCode = (error) => {
|
|
714
708
|
if (error.response?.text === PLAYLIST_INVALID_TEXT) {
|
|
715
|
-
return
|
|
709
|
+
return import_core2.ErrorCode.PLAYLIST_INVALID;
|
|
716
710
|
}
|
|
717
711
|
if (error.details === "bufferFullError") {
|
|
718
|
-
return
|
|
712
|
+
return import_core2.ErrorCode.MEDIA_BUFFER_FULL;
|
|
719
713
|
}
|
|
720
714
|
if (APPEND_ERROR_DETAILS.includes(error.details)) {
|
|
721
|
-
return
|
|
715
|
+
return import_core2.ErrorCode.MEDIA_APPEND_ERROR;
|
|
722
716
|
}
|
|
723
717
|
switch (error.type) {
|
|
724
718
|
case "network":
|
|
725
|
-
return
|
|
719
|
+
return import_core2.ErrorCode.MEDIA_NETWORK_ERROR;
|
|
726
720
|
case "media":
|
|
727
721
|
case "mux":
|
|
728
|
-
return
|
|
722
|
+
return import_core2.ErrorCode.MEDIA_DECODE_ERROR;
|
|
729
723
|
default:
|
|
730
|
-
return
|
|
724
|
+
return import_core2.ErrorCode.PLAYBACK_FAILED;
|
|
731
725
|
}
|
|
732
726
|
};
|
|
733
727
|
const buildErrorDetail = (error, retriesExhausted) => {
|
|
@@ -740,7 +734,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
740
734
|
if (typeof error.response?.code === "number" && error.response.code > 0) {
|
|
741
735
|
detail.httpStatus = error.response.code;
|
|
742
736
|
}
|
|
743
|
-
const url = sanitizeUrl(error.url);
|
|
737
|
+
const url = (0, import_core.sanitizeUrl)(error.url);
|
|
744
738
|
if (url) {
|
|
745
739
|
detail.url = url;
|
|
746
740
|
}
|
|
@@ -1055,7 +1049,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1055
1049
|
if (resolved || session !== loadSession) return;
|
|
1056
1050
|
resolved = true;
|
|
1057
1051
|
releaseAbort();
|
|
1058
|
-
api?.logger.error(`HLS load timed out after ${timeout_ms}ms`, { src: sanitizeUrl(src) });
|
|
1052
|
+
api?.logger.error(`HLS load timed out after ${timeout_ms}ms`, { src: (0, import_core.sanitizeUrl)(src) });
|
|
1059
1053
|
const timeoutError = {
|
|
1060
1054
|
type: "network",
|
|
1061
1055
|
details: "Video took too long to load (network timeout)",
|
|
@@ -1135,7 +1129,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1135
1129
|
api?.setState("playbackState", "error");
|
|
1136
1130
|
api?.setState("buffering", false);
|
|
1137
1131
|
api?.emit("error", {
|
|
1138
|
-
code: trigger ? mapFatalErrorCode(trigger) :
|
|
1132
|
+
code: trigger ? mapFatalErrorCode(trigger) : import_core2.ErrorCode.PLAYBACK_FAILED,
|
|
1139
1133
|
message: `HLS auto-reconnect gave up after ${attempts} attempts over ${Math.round(elapsedMs / 1e3)}s`,
|
|
1140
1134
|
fatal: true,
|
|
1141
1135
|
timestamp: Date.now(),
|
|
@@ -1208,7 +1202,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1208
1202
|
const was_live = api.getState("live");
|
|
1209
1203
|
const was_native = isNative;
|
|
1210
1204
|
const resume_position = reconnectResumePosition;
|
|
1211
|
-
api.logger.info(`Auto-reconnect attempt ${reconnectAttempts}`, { src: sanitizeUrl(saved_src) });
|
|
1205
|
+
api.logger.info(`Auto-reconnect attempt ${reconnectAttempts}`, { src: (0, import_core.sanitizeUrl)(saved_src) });
|
|
1212
1206
|
try {
|
|
1213
1207
|
teardownPipeline(new Error("HLS load cancelled: reconnecting"));
|
|
1214
1208
|
networkRetryCount = 0;
|
|
@@ -1412,7 +1406,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1412
1406
|
},
|
|
1413
1407
|
async loadSource(src) {
|
|
1414
1408
|
if (!api) throw new Error("Plugin not initialized");
|
|
1415
|
-
api.logger.info(`Loading HLS source${variant.logSuffix}`, { src: sanitizeUrl(src) });
|
|
1409
|
+
api.logger.info(`Loading HLS source${variant.logSuffix}`, { src: (0, import_core.sanitizeUrl)(src) });
|
|
1416
1410
|
const session = ++loadSession;
|
|
1417
1411
|
cancelReconnect();
|
|
1418
1412
|
hasPlayedContent = false;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './
|
|
2
|
-
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel
|
|
3
|
-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-DnvcTuSn.cjs';
|
|
2
|
+
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel } from './types-DnvcTuSn.cjs';
|
|
3
|
+
export { sanitizeUrl } from '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* HLS Provider Plugin for Scarlett Player
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './
|
|
2
|
-
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel
|
|
3
|
-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-DnvcTuSn.js';
|
|
2
|
+
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel } from './types-DnvcTuSn.js';
|
|
3
|
+
export { sanitizeUrl } from '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* HLS Provider Plugin for Scarlett Player
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
__export,
|
|
3
3
|
createHLSPluginWith,
|
|
4
4
|
sanitizeUrl
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NVPSLRJY.js";
|
|
6
6
|
|
|
7
7
|
// src/hls-loader.ts
|
|
8
8
|
var hls_loader_exports = {};
|
|
@@ -13,7 +13,6 @@ __export(hls_loader_exports, {
|
|
|
13
13
|
isHlsJsSupported: () => isHlsJsSupported,
|
|
14
14
|
loadHlsJs: () => loadHlsJs,
|
|
15
15
|
resetLoader: () => resetLoader,
|
|
16
|
-
shouldPreferNativeHLS: () => shouldPreferNativeHLS,
|
|
17
16
|
supportsNativeHLS: () => supportsNativeHLS
|
|
18
17
|
});
|
|
19
18
|
var hlsConstructor = null;
|
|
@@ -23,13 +22,6 @@ function supportsNativeHLS() {
|
|
|
23
22
|
const video = document.createElement("video");
|
|
24
23
|
return video.canPlayType("application/vnd.apple.mpegurl") !== "";
|
|
25
24
|
}
|
|
26
|
-
function shouldPreferNativeHLS() {
|
|
27
|
-
if (!supportsNativeHLS()) return false;
|
|
28
|
-
if (typeof navigator === "undefined") return false;
|
|
29
|
-
const ua = navigator.userAgent;
|
|
30
|
-
const isSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/CriOS/.test(ua);
|
|
31
|
-
return isSafari;
|
|
32
|
-
}
|
|
33
25
|
function isHlsJsSupported() {
|
|
34
26
|
if (hlsConstructor) {
|
|
35
27
|
return hlsConstructor.isSupported();
|
package/dist/light.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var light_exports = {};
|
|
|
32
32
|
__export(light_exports, {
|
|
33
33
|
createHLSPlugin: () => createHLSPlugin,
|
|
34
34
|
default: () => light_default,
|
|
35
|
-
sanitizeUrl: () => sanitizeUrl
|
|
35
|
+
sanitizeUrl: () => import_core.sanitizeUrl
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(light_exports);
|
|
38
38
|
|
|
@@ -45,7 +45,6 @@ __export(hls_loader_light_exports, {
|
|
|
45
45
|
isHlsJsSupported: () => isHlsJsSupported,
|
|
46
46
|
loadHlsJs: () => loadHlsJs,
|
|
47
47
|
resetLoader: () => resetLoader,
|
|
48
|
-
shouldPreferNativeHLS: () => shouldPreferNativeHLS,
|
|
49
48
|
supportsNativeHLS: () => supportsNativeHLS
|
|
50
49
|
});
|
|
51
50
|
var hlsConstructor = null;
|
|
@@ -55,13 +54,6 @@ function supportsNativeHLS() {
|
|
|
55
54
|
const video = document.createElement("video");
|
|
56
55
|
return video.canPlayType("application/vnd.apple.mpegurl") !== "";
|
|
57
56
|
}
|
|
58
|
-
function shouldPreferNativeHLS() {
|
|
59
|
-
if (!supportsNativeHLS()) return false;
|
|
60
|
-
if (typeof navigator === "undefined") return false;
|
|
61
|
-
const ua = navigator.userAgent;
|
|
62
|
-
const isSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/CriOS/.test(ua);
|
|
63
|
-
return isSafari;
|
|
64
|
-
}
|
|
65
57
|
function isHlsJsSupported() {
|
|
66
58
|
if (hlsConstructor) {
|
|
67
59
|
return hlsConstructor.isSupported();
|
|
@@ -111,7 +103,7 @@ function resetLoader() {
|
|
|
111
103
|
}
|
|
112
104
|
|
|
113
105
|
// src/create-hls-plugin.ts
|
|
114
|
-
var
|
|
106
|
+
var import_core2 = require("@scarlett-player/core");
|
|
115
107
|
|
|
116
108
|
// src/quality.ts
|
|
117
109
|
function formatLevel(level) {
|
|
@@ -172,6 +164,9 @@ function getInitialBandwidthEstimate(overrideBps) {
|
|
|
172
164
|
return HLS_DEFAULT_ESTIMATE;
|
|
173
165
|
}
|
|
174
166
|
|
|
167
|
+
// src/sanitize-url.ts
|
|
168
|
+
var import_core = require("@scarlett-player/core");
|
|
169
|
+
|
|
175
170
|
// src/event-map.ts
|
|
176
171
|
var HLS_ERROR_TYPES = {
|
|
177
172
|
NETWORK_ERROR: "networkError",
|
|
@@ -193,11 +188,19 @@ function mapErrorType(hlsType) {
|
|
|
193
188
|
}
|
|
194
189
|
}
|
|
195
190
|
function parseHlsError(data) {
|
|
191
|
+
const frag = data.frag;
|
|
192
|
+
const response = data.response;
|
|
193
|
+
const context = data.context;
|
|
196
194
|
return {
|
|
197
195
|
type: mapErrorType(data.type),
|
|
198
196
|
details: data.details || "Unknown error",
|
|
199
197
|
fatal: data.fatal || false,
|
|
200
|
-
|
|
198
|
+
// hls.js puts the request URL in a different place per error type:
|
|
199
|
+
// playlist errors set data.url, while fragment and key load errors set
|
|
200
|
+
// data.url not at all and carry it on data.frag.url and data.response.url.
|
|
201
|
+
// Reading only data.url dropped the failing segment from every diagnostic
|
|
202
|
+
// an origin outage produces - which is the case the diagnostics exist for.
|
|
203
|
+
url: data.url ?? frag?.url ?? response?.url ?? context?.url,
|
|
201
204
|
reason: data.reason,
|
|
202
205
|
response: data.response
|
|
203
206
|
};
|
|
@@ -327,14 +330,16 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
327
330
|
api.logger.error(`HLS fatal error: ${error.details} (type=${error.type})`, {
|
|
328
331
|
type: error.type,
|
|
329
332
|
details: error.details,
|
|
330
|
-
|
|
333
|
+
status: error.response?.code,
|
|
334
|
+
url: (0, import_core.sanitizeUrl)(error.url)
|
|
331
335
|
});
|
|
332
336
|
} else {
|
|
333
337
|
api.logger.warn(`HLS error: ${error.details} (type=${error.type}, fatal=${error.fatal})`, {
|
|
334
338
|
type: error.type,
|
|
335
339
|
details: error.details,
|
|
336
340
|
fatal: error.fatal,
|
|
337
|
-
|
|
341
|
+
status: error.response?.code,
|
|
342
|
+
url: (0, import_core.sanitizeUrl)(error.url)
|
|
338
343
|
});
|
|
339
344
|
}
|
|
340
345
|
callbacks.onError?.(error);
|
|
@@ -540,19 +545,8 @@ function createValidatingPlaylistLoader(Hls) {
|
|
|
540
545
|
};
|
|
541
546
|
}
|
|
542
547
|
|
|
543
|
-
// src/sanitize-url.ts
|
|
544
|
-
function sanitizeUrl(url) {
|
|
545
|
-
if (!url) return void 0;
|
|
546
|
-
try {
|
|
547
|
-
const parsed = new URL(url);
|
|
548
|
-
return `${parsed.origin}${parsed.pathname}`;
|
|
549
|
-
} catch {
|
|
550
|
-
return void 0;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
548
|
// src/version.ts
|
|
555
|
-
var PKG_VERSION = true ? "1.
|
|
549
|
+
var PKG_VERSION = true ? "1.11.0" : "0.0.0-dev";
|
|
556
550
|
|
|
557
551
|
// src/create-hls-plugin.ts
|
|
558
552
|
var DEFAULT_CONFIG = {
|
|
@@ -712,22 +706,22 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
712
706
|
];
|
|
713
707
|
const mapFatalErrorCode = (error) => {
|
|
714
708
|
if (error.response?.text === PLAYLIST_INVALID_TEXT) {
|
|
715
|
-
return
|
|
709
|
+
return import_core2.ErrorCode.PLAYLIST_INVALID;
|
|
716
710
|
}
|
|
717
711
|
if (error.details === "bufferFullError") {
|
|
718
|
-
return
|
|
712
|
+
return import_core2.ErrorCode.MEDIA_BUFFER_FULL;
|
|
719
713
|
}
|
|
720
714
|
if (APPEND_ERROR_DETAILS.includes(error.details)) {
|
|
721
|
-
return
|
|
715
|
+
return import_core2.ErrorCode.MEDIA_APPEND_ERROR;
|
|
722
716
|
}
|
|
723
717
|
switch (error.type) {
|
|
724
718
|
case "network":
|
|
725
|
-
return
|
|
719
|
+
return import_core2.ErrorCode.MEDIA_NETWORK_ERROR;
|
|
726
720
|
case "media":
|
|
727
721
|
case "mux":
|
|
728
|
-
return
|
|
722
|
+
return import_core2.ErrorCode.MEDIA_DECODE_ERROR;
|
|
729
723
|
default:
|
|
730
|
-
return
|
|
724
|
+
return import_core2.ErrorCode.PLAYBACK_FAILED;
|
|
731
725
|
}
|
|
732
726
|
};
|
|
733
727
|
const buildErrorDetail = (error, retriesExhausted) => {
|
|
@@ -740,7 +734,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
740
734
|
if (typeof error.response?.code === "number" && error.response.code > 0) {
|
|
741
735
|
detail.httpStatus = error.response.code;
|
|
742
736
|
}
|
|
743
|
-
const url = sanitizeUrl(error.url);
|
|
737
|
+
const url = (0, import_core.sanitizeUrl)(error.url);
|
|
744
738
|
if (url) {
|
|
745
739
|
detail.url = url;
|
|
746
740
|
}
|
|
@@ -1055,7 +1049,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1055
1049
|
if (resolved || session !== loadSession) return;
|
|
1056
1050
|
resolved = true;
|
|
1057
1051
|
releaseAbort();
|
|
1058
|
-
api?.logger.error(`HLS load timed out after ${timeout_ms}ms`, { src: sanitizeUrl(src) });
|
|
1052
|
+
api?.logger.error(`HLS load timed out after ${timeout_ms}ms`, { src: (0, import_core.sanitizeUrl)(src) });
|
|
1059
1053
|
const timeoutError = {
|
|
1060
1054
|
type: "network",
|
|
1061
1055
|
details: "Video took too long to load (network timeout)",
|
|
@@ -1135,7 +1129,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1135
1129
|
api?.setState("playbackState", "error");
|
|
1136
1130
|
api?.setState("buffering", false);
|
|
1137
1131
|
api?.emit("error", {
|
|
1138
|
-
code: trigger ? mapFatalErrorCode(trigger) :
|
|
1132
|
+
code: trigger ? mapFatalErrorCode(trigger) : import_core2.ErrorCode.PLAYBACK_FAILED,
|
|
1139
1133
|
message: `HLS auto-reconnect gave up after ${attempts} attempts over ${Math.round(elapsedMs / 1e3)}s`,
|
|
1140
1134
|
fatal: true,
|
|
1141
1135
|
timestamp: Date.now(),
|
|
@@ -1208,7 +1202,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1208
1202
|
const was_live = api.getState("live");
|
|
1209
1203
|
const was_native = isNative;
|
|
1210
1204
|
const resume_position = reconnectResumePosition;
|
|
1211
|
-
api.logger.info(`Auto-reconnect attempt ${reconnectAttempts}`, { src: sanitizeUrl(saved_src) });
|
|
1205
|
+
api.logger.info(`Auto-reconnect attempt ${reconnectAttempts}`, { src: (0, import_core.sanitizeUrl)(saved_src) });
|
|
1212
1206
|
try {
|
|
1213
1207
|
teardownPipeline(new Error("HLS load cancelled: reconnecting"));
|
|
1214
1208
|
networkRetryCount = 0;
|
|
@@ -1412,7 +1406,7 @@ function createHLSPluginWith(loader, variant, config) {
|
|
|
1412
1406
|
},
|
|
1413
1407
|
async loadSource(src) {
|
|
1414
1408
|
if (!api) throw new Error("Plugin not initialized");
|
|
1415
|
-
api.logger.info(`Loading HLS source${variant.logSuffix}`, { src: sanitizeUrl(src) });
|
|
1409
|
+
api.logger.info(`Loading HLS source${variant.logSuffix}`, { src: (0, import_core.sanitizeUrl)(src) });
|
|
1416
1410
|
const session = ++loadSession;
|
|
1417
1411
|
cancelReconnect();
|
|
1418
1412
|
hasPlayedContent = false;
|
package/dist/light.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './
|
|
2
|
-
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel
|
|
3
|
-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-DnvcTuSn.cjs';
|
|
2
|
+
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel } from './types-DnvcTuSn.cjs';
|
|
3
|
+
export { sanitizeUrl } from '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* HLS Provider Plugin - Light Build
|
package/dist/light.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './
|
|
2
|
-
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel
|
|
3
|
-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-DnvcTuSn.js';
|
|
2
|
+
export { b as HLSError, c as HLSLiveInfo, a as HLSQualityLevel } from './types-DnvcTuSn.js';
|
|
3
|
+
export { sanitizeUrl } from '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* HLS Provider Plugin - Light Build
|
package/dist/light.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
__export,
|
|
3
3
|
createHLSPluginWith,
|
|
4
4
|
sanitizeUrl
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NVPSLRJY.js";
|
|
6
6
|
|
|
7
7
|
// src/hls-loader-light.ts
|
|
8
8
|
var hls_loader_light_exports = {};
|
|
@@ -13,7 +13,6 @@ __export(hls_loader_light_exports, {
|
|
|
13
13
|
isHlsJsSupported: () => isHlsJsSupported,
|
|
14
14
|
loadHlsJs: () => loadHlsJs,
|
|
15
15
|
resetLoader: () => resetLoader,
|
|
16
|
-
shouldPreferNativeHLS: () => shouldPreferNativeHLS,
|
|
17
16
|
supportsNativeHLS: () => supportsNativeHLS
|
|
18
17
|
});
|
|
19
18
|
var hlsConstructor = null;
|
|
@@ -23,13 +22,6 @@ function supportsNativeHLS() {
|
|
|
23
22
|
const video = document.createElement("video");
|
|
24
23
|
return video.canPlayType("application/vnd.apple.mpegurl") !== "";
|
|
25
24
|
}
|
|
26
|
-
function shouldPreferNativeHLS() {
|
|
27
|
-
if (!supportsNativeHLS()) return false;
|
|
28
|
-
if (typeof navigator === "undefined") return false;
|
|
29
|
-
const ua = navigator.userAgent;
|
|
30
|
-
const isSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/CriOS/.test(ua);
|
|
31
|
-
return isSafari;
|
|
32
|
-
}
|
|
33
25
|
function isHlsJsSupported() {
|
|
34
26
|
if (hlsConstructor) {
|
|
35
27
|
return hlsConstructor.isSupported();
|
|
@@ -140,29 +140,4 @@ interface IHLSPlugin extends Plugin<HLSPluginConfig> {
|
|
|
140
140
|
switchToHlsJs(): Promise<void>;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
* URL sanitizer for error telemetry.
|
|
145
|
-
*
|
|
146
|
-
* Segment and playlist URLs are the single most useful field when
|
|
147
|
-
* diagnosing a dead stream, and the single most dangerous one to hand to a
|
|
148
|
-
* consumer's telemetry: signed-URL tokens, HMAC signatures, and session ids
|
|
149
|
-
* all live in the query string. Stripping the whole query (and fragment) is
|
|
150
|
-
* the privacy-safe default for EVERY consumer; anyone who genuinely needs
|
|
151
|
-
* the parameters can subscribe to hls.js directly.
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Reduce a URL to origin + pathname, dropping the query string and fragment.
|
|
155
|
-
*
|
|
156
|
-
* @param url - Raw URL from a provider error, if any
|
|
157
|
-
* @returns Sanitized `origin + pathname`, or undefined when there is
|
|
158
|
-
* nothing usable to report (absent or unparseable URL)
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* sanitizeUrl('https://cdn.example.com/live/x.m3u8?token=secret#frag');
|
|
163
|
-
* // 'https://cdn.example.com/live/x.m3u8'
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
declare function sanitizeUrl(url: string | undefined | null): string | undefined;
|
|
167
|
-
|
|
168
|
-
export { type HLSPluginConfig as H, type IHLSPlugin as I, type HLSQualityLevel as a, type HLSError as b, type HLSLiveInfo as c, sanitizeUrl as s };
|
|
143
|
+
export type { HLSPluginConfig as H, IHLSPlugin as I, HLSQualityLevel as a, HLSError as b, HLSLiveInfo as c };
|
|
@@ -140,29 +140,4 @@ interface IHLSPlugin extends Plugin<HLSPluginConfig> {
|
|
|
140
140
|
switchToHlsJs(): Promise<void>;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
* URL sanitizer for error telemetry.
|
|
145
|
-
*
|
|
146
|
-
* Segment and playlist URLs are the single most useful field when
|
|
147
|
-
* diagnosing a dead stream, and the single most dangerous one to hand to a
|
|
148
|
-
* consumer's telemetry: signed-URL tokens, HMAC signatures, and session ids
|
|
149
|
-
* all live in the query string. Stripping the whole query (and fragment) is
|
|
150
|
-
* the privacy-safe default for EVERY consumer; anyone who genuinely needs
|
|
151
|
-
* the parameters can subscribe to hls.js directly.
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Reduce a URL to origin + pathname, dropping the query string and fragment.
|
|
155
|
-
*
|
|
156
|
-
* @param url - Raw URL from a provider error, if any
|
|
157
|
-
* @returns Sanitized `origin + pathname`, or undefined when there is
|
|
158
|
-
* nothing usable to report (absent or unparseable URL)
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* sanitizeUrl('https://cdn.example.com/live/x.m3u8?token=secret#frag');
|
|
163
|
-
* // 'https://cdn.example.com/live/x.m3u8'
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
declare function sanitizeUrl(url: string | undefined | null): string | undefined;
|
|
167
|
-
|
|
168
|
-
export { type HLSPluginConfig as H, type IHLSPlugin as I, type HLSQualityLevel as a, type HLSError as b, type HLSLiveInfo as c, sanitizeUrl as s };
|
|
143
|
+
export type { HLSPluginConfig as H, IHLSPlugin as I, HLSQualityLevel as a, HLSError as b, HLSLiveInfo as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scarlett-player/hls",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "HLS Provider Plugin for Scarlett Player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"vitest": "^1.6.0",
|
|
38
38
|
"@vitest/coverage-v8": "^1.6.0",
|
|
39
39
|
"jsdom": "^24.0.0",
|
|
40
|
-
"@scarlett-player/core": "1.
|
|
40
|
+
"@scarlett-player/core": "1.11.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"video",
|