rx-player 4.2.0-dev.2024090500 → 4.2.0-dev.2024091000
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/CHANGELOG.md +5 -2
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/compat/browser_detection.d.ts +3 -1
- package/dist/commonjs/compat/browser_detection.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_detection.js +7 -1
- package/dist/commonjs/compat/can_reuse_media_keys.d.ts +4 -0
- package/dist/commonjs/compat/can_reuse_media_keys.d.ts.map +1 -1
- package/dist/commonjs/compat/can_reuse_media_keys.js +5 -1
- package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts +12 -0
- package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
- package/dist/commonjs/core/cmcd/cmcd_data_builder.js +27 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +24 -0
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/segment/segment_queue.js +8 -7
- package/dist/commonjs/core/main/worker/worker_main.js +4 -0
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +2 -2
- package/dist/commonjs/parsers/manifest/dash/common/resolve_base_urls.js +2 -2
- package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +2 -2
- package/dist/commonjs/parsers/manifest/smooth/create_parser.js +2 -2
- package/dist/commonjs/transports/dash/construct_segment_url.js +2 -2
- package/dist/commonjs/transports/smooth/utils.js +2 -2
- package/dist/commonjs/utils/logger.d.ts.map +1 -1
- package/dist/commonjs/utils/logger.js +6 -7
- package/dist/commonjs/utils/{resolve_url.d.ts → url-utils.d.ts} +15 -4
- package/dist/commonjs/utils/url-utils.d.ts.map +1 -0
- package/dist/commonjs/utils/{resolve_url.js → url-utils.js} +71 -2
- package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/compat/browser_detection.d.ts +3 -1
- package/dist/es2017/compat/browser_detection.d.ts.map +1 -1
- package/dist/es2017/compat/browser_detection.js +10 -1
- package/dist/es2017/compat/can_reuse_media_keys.d.ts +4 -0
- package/dist/es2017/compat/can_reuse_media_keys.d.ts.map +1 -1
- package/dist/es2017/compat/can_reuse_media_keys.js +6 -2
- package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts +12 -0
- package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
- package/dist/es2017/core/cmcd/cmcd_data_builder.js +27 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +24 -0
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/segment/segment_queue.js +8 -7
- package/dist/es2017/core/main/worker/worker_main.js +4 -0
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +1 -1
- package/dist/es2017/parsers/manifest/dash/common/resolve_base_urls.js +1 -1
- package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -1
- package/dist/es2017/parsers/manifest/smooth/create_parser.js +1 -1
- package/dist/es2017/transports/dash/construct_segment_url.js +1 -1
- package/dist/es2017/transports/smooth/utils.js +1 -1
- package/dist/es2017/utils/logger.d.ts.map +1 -1
- package/dist/es2017/utils/logger.js +6 -7
- package/dist/es2017/utils/{resolve_url.d.ts → url-utils.d.ts} +15 -4
- package/dist/es2017/utils/url-utils.d.ts.map +1 -0
- package/dist/es2017/utils/{resolve_url.js → url-utils.js} +71 -3
- package/dist/rx-player.js +253 -181
- package/dist/rx-player.min.js +18 -18
- package/dist/worker.js +8 -8
- package/package.json +5 -12
- package/src/README.md +7 -7
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/can_reuse_media_keys.test.ts +24 -1
- package/src/compat/browser_detection.ts +13 -4
- package/src/compat/can_reuse_media_keys.ts +6 -2
- package/src/core/cmcd/cmcd_data_builder.ts +68 -2
- package/src/core/fetchers/segment/segment_fetcher.ts +24 -0
- package/src/core/fetchers/segment/segment_queue.ts +11 -9
- package/src/core/main/worker/worker_main.ts +4 -0
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +8 -2
- package/src/main_thread/api/public_api.ts +2 -2
- package/src/parsers/manifest/dash/common/parse_mpd.ts +1 -1
- package/src/parsers/manifest/dash/common/resolve_base_urls.ts +1 -1
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +1 -1
- package/src/parsers/manifest/smooth/create_parser.ts +1 -1
- package/src/transports/dash/construct_segment_url.ts +1 -1
- package/src/transports/smooth/utils.ts +1 -1
- package/src/utils/__tests__/{resolve_url.test.ts → url-utils.test.ts} +148 -1
- package/src/utils/logger.ts +6 -7
- package/src/utils/{resolve_url.ts → url-utils.ts} +83 -5
- package/dist/commonjs/utils/resolve_url.d.ts.map +0 -1
- package/dist/es2017/utils/resolve_url.d.ts.map +0 -1
|
@@ -19,9 +19,9 @@ import startsWith from "./starts_with";
|
|
|
19
19
|
// Scheme part of an url (e.g. "http://").
|
|
20
20
|
const schemeRe = /^(?:[a-z]+:)?\/\//i;
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
23
|
* Match the different components of an URL.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* foo://example.com:8042/over/there?name=ferret#nose
|
|
26
26
|
\_/ \______________/\_________/ \_________/ \__/
|
|
27
27
|
| | | | |
|
|
@@ -68,6 +68,85 @@ function getFilenameIndexInUrl(url: string): number {
|
|
|
68
68
|
return indexOfLastSlash + 1;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Take two URLs and try to construct a relative URL for the second (`newUrl`)
|
|
73
|
+
* relative to the first (`baseUrl`).
|
|
74
|
+
*
|
|
75
|
+
* Returns `null` if they appear to be on different domains, depend on
|
|
76
|
+
* different schemes or if we don't have enough information to compute the
|
|
77
|
+
* relative URL.
|
|
78
|
+
* @param {string} baseUrl
|
|
79
|
+
* @param {string} newUrl
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
function getRelativeUrl(baseUrl: string, newUrl: string): string | null {
|
|
83
|
+
const baseParts = parseURL(baseUrl);
|
|
84
|
+
const newParts = parseURL(newUrl);
|
|
85
|
+
if (
|
|
86
|
+
baseParts.scheme !== newParts.scheme ||
|
|
87
|
+
baseParts.authority !== newParts.authority
|
|
88
|
+
) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (
|
|
92
|
+
// if base and new path are mixed between absolute and relative path, return null
|
|
93
|
+
(baseParts.path[0] !== undefined &&
|
|
94
|
+
baseParts.path[0] !== "/" &&
|
|
95
|
+
newParts.path[0] === "/") ||
|
|
96
|
+
(newParts.path[0] !== undefined &&
|
|
97
|
+
newParts.path[0] !== "/" &&
|
|
98
|
+
baseParts.path[0] === "/")
|
|
99
|
+
) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const baseNormalizedPath = removeDotSegment(baseParts.path);
|
|
104
|
+
const newNormalizedPath = removeDotSegment(newParts.path);
|
|
105
|
+
let relativePath: string | undefined;
|
|
106
|
+
if (baseNormalizedPath === newNormalizedPath) {
|
|
107
|
+
relativePath = "";
|
|
108
|
+
} else {
|
|
109
|
+
const basePathSplitted = baseNormalizedPath.split("/");
|
|
110
|
+
// remove everything after the last trailing /
|
|
111
|
+
basePathSplitted.pop();
|
|
112
|
+
|
|
113
|
+
const newPathSplitted = newNormalizedPath.split("/");
|
|
114
|
+
|
|
115
|
+
while (
|
|
116
|
+
basePathSplitted.length > 0 &&
|
|
117
|
+
newPathSplitted.length > 0 &&
|
|
118
|
+
basePathSplitted[0] === newPathSplitted[0]
|
|
119
|
+
) {
|
|
120
|
+
basePathSplitted.shift();
|
|
121
|
+
newPathSplitted.shift();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
while (basePathSplitted.length > 0) {
|
|
125
|
+
basePathSplitted.shift();
|
|
126
|
+
newPathSplitted.unshift("..");
|
|
127
|
+
}
|
|
128
|
+
let pathJoined = newPathSplitted.join("/");
|
|
129
|
+
if (pathJoined.endsWith("../") || pathJoined.endsWith("./")) {
|
|
130
|
+
pathJoined = pathJoined.slice(0, pathJoined.length - 1);
|
|
131
|
+
}
|
|
132
|
+
relativePath = pathJoined === "" ? "." : pathJoined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let result = relativePath;
|
|
136
|
+
if (relativePath === "" && newParts.query === baseParts.query) {
|
|
137
|
+
// path and query is the same, we don't need to rewrite it
|
|
138
|
+
} else if (newParts.query) {
|
|
139
|
+
result += "?";
|
|
140
|
+
result += newParts.query;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (newParts.fragment) {
|
|
144
|
+
result += "#";
|
|
145
|
+
result += newParts.fragment;
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
71
150
|
/**
|
|
72
151
|
* Resolve the output URL from the baseURL and the relative reference as
|
|
73
152
|
* specified by RFC 3986 section 5.
|
|
@@ -259,7 +338,7 @@ function mergePaths(baseParts: IParsedURL, relativePath: string): string {
|
|
|
259
338
|
* @param {...(string|undefined)} args - The URL segments to resolve.
|
|
260
339
|
* @returns {string} The resolved URL as a string.
|
|
261
340
|
*/
|
|
262
|
-
|
|
341
|
+
function resolveURL(...args: Array<string | undefined>): string {
|
|
263
342
|
const filteredArgs = args.filter((val) => val !== "");
|
|
264
343
|
const len = filteredArgs.length;
|
|
265
344
|
if (len === 0) {
|
|
@@ -276,5 +355,4 @@ export function resolveURL(...args: Array<string | undefined>): string {
|
|
|
276
355
|
}
|
|
277
356
|
}
|
|
278
357
|
|
|
279
|
-
export { getFilenameIndexInUrl };
|
|
280
|
-
export default resolveURL;
|
|
358
|
+
export { getFilenameIndexInUrl, getRelativeUrl, resolveURL };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_url.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve_url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuBH;;;;;;;GAOG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAuBlD;AAsLD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAerE;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_url.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve_url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuBH;;;;;;;GAOG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAuBlD;AAsLD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAerE;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,eAAe,UAAU,CAAC"}
|