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.
Files changed (88) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/browser_detection.d.ts +3 -1
  6. package/dist/commonjs/compat/browser_detection.d.ts.map +1 -1
  7. package/dist/commonjs/compat/browser_detection.js +7 -1
  8. package/dist/commonjs/compat/can_reuse_media_keys.d.ts +4 -0
  9. package/dist/commonjs/compat/can_reuse_media_keys.d.ts.map +1 -1
  10. package/dist/commonjs/compat/can_reuse_media_keys.js +5 -1
  11. package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts +12 -0
  12. package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
  13. package/dist/commonjs/core/cmcd/cmcd_data_builder.js +27 -1
  14. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +24 -0
  15. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  16. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  17. package/dist/commonjs/core/fetchers/segment/segment_queue.js +8 -7
  18. package/dist/commonjs/core/main/worker/worker_main.js +4 -0
  19. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
  20. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
  21. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  22. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +2 -2
  23. package/dist/commonjs/parsers/manifest/dash/common/resolve_base_urls.js +2 -2
  24. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +2 -2
  25. package/dist/commonjs/parsers/manifest/smooth/create_parser.js +2 -2
  26. package/dist/commonjs/transports/dash/construct_segment_url.js +2 -2
  27. package/dist/commonjs/transports/smooth/utils.js +2 -2
  28. package/dist/commonjs/utils/logger.d.ts.map +1 -1
  29. package/dist/commonjs/utils/logger.js +6 -7
  30. package/dist/commonjs/utils/{resolve_url.d.ts → url-utils.d.ts} +15 -4
  31. package/dist/commonjs/utils/url-utils.d.ts.map +1 -0
  32. package/dist/commonjs/utils/{resolve_url.js → url-utils.js} +71 -2
  33. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  34. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  35. package/dist/es2017/compat/browser_detection.d.ts +3 -1
  36. package/dist/es2017/compat/browser_detection.d.ts.map +1 -1
  37. package/dist/es2017/compat/browser_detection.js +10 -1
  38. package/dist/es2017/compat/can_reuse_media_keys.d.ts +4 -0
  39. package/dist/es2017/compat/can_reuse_media_keys.d.ts.map +1 -1
  40. package/dist/es2017/compat/can_reuse_media_keys.js +6 -2
  41. package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts +12 -0
  42. package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts.map +1 -1
  43. package/dist/es2017/core/cmcd/cmcd_data_builder.js +27 -1
  44. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +24 -0
  45. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  46. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  47. package/dist/es2017/core/fetchers/segment/segment_queue.js +8 -7
  48. package/dist/es2017/core/main/worker/worker_main.js +4 -0
  49. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
  50. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
  51. package/dist/es2017/main_thread/api/public_api.js +2 -2
  52. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +1 -1
  53. package/dist/es2017/parsers/manifest/dash/common/resolve_base_urls.js +1 -1
  54. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -1
  55. package/dist/es2017/parsers/manifest/smooth/create_parser.js +1 -1
  56. package/dist/es2017/transports/dash/construct_segment_url.js +1 -1
  57. package/dist/es2017/transports/smooth/utils.js +1 -1
  58. package/dist/es2017/utils/logger.d.ts.map +1 -1
  59. package/dist/es2017/utils/logger.js +6 -7
  60. package/dist/es2017/utils/{resolve_url.d.ts → url-utils.d.ts} +15 -4
  61. package/dist/es2017/utils/url-utils.d.ts.map +1 -0
  62. package/dist/es2017/utils/{resolve_url.js → url-utils.js} +71 -3
  63. package/dist/rx-player.js +253 -181
  64. package/dist/rx-player.min.js +18 -18
  65. package/dist/worker.js +8 -8
  66. package/package.json +5 -12
  67. package/src/README.md +7 -7
  68. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  69. package/src/compat/__tests__/can_reuse_media_keys.test.ts +24 -1
  70. package/src/compat/browser_detection.ts +13 -4
  71. package/src/compat/can_reuse_media_keys.ts +6 -2
  72. package/src/core/cmcd/cmcd_data_builder.ts +68 -2
  73. package/src/core/fetchers/segment/segment_fetcher.ts +24 -0
  74. package/src/core/fetchers/segment/segment_queue.ts +11 -9
  75. package/src/core/main/worker/worker_main.ts +4 -0
  76. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +8 -2
  77. package/src/main_thread/api/public_api.ts +2 -2
  78. package/src/parsers/manifest/dash/common/parse_mpd.ts +1 -1
  79. package/src/parsers/manifest/dash/common/resolve_base_urls.ts +1 -1
  80. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +1 -1
  81. package/src/parsers/manifest/smooth/create_parser.ts +1 -1
  82. package/src/transports/dash/construct_segment_url.ts +1 -1
  83. package/src/transports/smooth/utils.ts +1 -1
  84. package/src/utils/__tests__/{resolve_url.test.ts → url-utils.test.ts} +148 -1
  85. package/src/utils/logger.ts +6 -7
  86. package/src/utils/{resolve_url.ts → url-utils.ts} +83 -5
  87. package/dist/commonjs/utils/resolve_url.d.ts.map +0 -1
  88. 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
- export function resolveURL(...args: Array<string | undefined>): string {
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"}