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
@@ -45,5 +45,7 @@ declare let isPlayStation4: boolean;
45
45
  declare let isPlayStation5: boolean;
46
46
  /** `true` for the Xbox game consoles. */
47
47
  declare let isXbox: boolean;
48
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPhilipsNetTv, isPlayStation4, isPlayStation5, isXbox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
48
+ /** `true` for specific A1 STB: KSTB 40xx from Kaon Media. */
49
+ declare let isA1KStb40xx: boolean;
50
+ export { isEdgeChromium, isFirefox, isIE11, isIEOrEdge, isSafariDesktop, isSafariMobile, isA1KStb40xx, isPanasonic, isPhilipsNetTv, isPlayStation4, isPlayStation5, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, isXbox, };
49
51
  //# sourceMappingURL=browser_detection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser_detection.d.ts","sourceRoot":"","sources":["../../../src/compat/browser_detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH,8CAA8C;AAC9C,QAAA,IAAI,cAAc,SAAQ,CAAC;AAE3B,qCAAqC;AACrC,QAAA,IAAI,MAAM,SAAQ,CAAC;AAEnB,4EAA4E;AAC5E,QAAA,IAAI,UAAU,SAAQ,CAAC;AAEvB,wCAAwC;AACxC,QAAA,IAAI,SAAS,SAAQ,CAAC;AAEtB,sEAAsE;AACtE,QAAA,IAAI,eAAe,SAAQ,CAAC;AAE5B,0DAA0D;AAC1D,QAAA,IAAI,cAAc,SAAQ,CAAC;AAE3B,wCAAwC;AACxC,QAAA,IAAI,gBAAgB,SAAQ,CAAC;AAE7B,kEAAkE;AAClE,QAAA,IAAI,OAAO,SAAQ,CAAC;AAEpB,6DAA6D;AAC7D,QAAA,IAAI,OA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C;AAExB,kDAAkD;AAClD,QAAA,IAAI,WAAW,SAAQ,CAAC;AAExB,oCAAoC;AACpC,QAAA,IAAI,WAAW,SAAQ,CAAC;AAExB,uDAAuD;AACvD,QAAA,IAAI,cAAc,SAAQ,CAAC;AAE3B,iDAAiD;AACjD,QAAA,IAAI,cAAc,SAAQ,CAAC;AAE3B,iDAAiD;AACjD,QAAA,IAAI,cAAc,SAAQ,CAAC;AAE3B,yCAAyC;AACzC,QAAA,IAAI,MAAM,SAAQ,CAAC;AAEnB,6DAA6D;AAC7D,QAAA,IAAI,YAAY,SAAQ,CAAC;AA+FzB,OAAO,EAEL,cAAc,EACd,SAAS,EACT,MAAM,EACN,UAAU,EACV,eAAe,EACf,cAAc,EAGd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,WAAW,EACX,WAAW,EACX,MAAM,GACP,CAAC"}
@@ -47,6 +47,8 @@ let isPlayStation4 = false;
47
47
  let isPlayStation5 = false;
48
48
  /** `true` for the Xbox game consoles. */
49
49
  let isXbox = false;
50
+ /** `true` for specific A1 STB: KSTB 40xx from Kaon Media. */
51
+ let isA1KStb40xx = false;
50
52
  (function findCurrentBrowser() {
51
53
  var _a, _b, _c;
52
54
  if (isNode) {
@@ -129,5 +131,12 @@ let isXbox = false;
129
131
  else if (navigator.userAgent.indexOf("Xbox") !== -1) {
130
132
  isXbox = true;
131
133
  }
134
+ else if (navigator.userAgent.indexOf("Model/a1-kstb40xx")) {
135
+ isA1KStb40xx = true;
136
+ }
132
137
  })();
133
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPhilipsNetTv, isPlayStation4, isPlayStation5, isXbox, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
138
+ export {
139
+ // browsers
140
+ isEdgeChromium, isFirefox, isIE11, isIEOrEdge, isSafariDesktop, isSafariMobile,
141
+ // specific devices
142
+ isA1KStb40xx, isPanasonic, isPhilipsNetTv, isPlayStation4, isPlayStation5, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, isXbox, };
@@ -9,6 +9,10 @@
9
9
  * HTMLMediaElement.
10
10
  * - (2024-08-23): Seen on Philips 2024 and 2023 in:
11
11
  * https://github.com/canalplus/rx-player/issues/1464
12
+ * - (2024-09-04): Another case seen on an "A1" set-top box model made by
13
+ * Kaonmedia we will call the KSTB40xx.
14
+ * It may share the problematic with other devices, but we have only seen
15
+ * the problem on this one for now.
12
16
  *
13
17
  * @returns {boolean}
14
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"can_reuse_media_keys.d.ts","sourceRoot":"","sources":["../../../src/compat/can_reuse_media_keys.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,OAAO,CAEnD"}
1
+ {"version":3,"file":"can_reuse_media_keys.d.ts","sourceRoot":"","sources":["../../../src/compat/can_reuse_media_keys.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,OAAO,CAEnD"}
@@ -1,4 +1,4 @@
1
- import { isPanasonic, isPhilipsNetTv, isWebOs } from "./browser_detection";
1
+ import { isA1KStb40xx, isPanasonic, isPhilipsNetTv, isWebOs } from "./browser_detection";
2
2
  /**
3
3
  * Returns `true` if a `MediaKeys` instance (the `Encrypted Media Extension`
4
4
  * concept) can be reused between contents.
@@ -10,9 +10,13 @@ import { isPanasonic, isPhilipsNetTv, isWebOs } from "./browser_detection";
10
10
  * HTMLMediaElement.
11
11
  * - (2024-08-23): Seen on Philips 2024 and 2023 in:
12
12
  * https://github.com/canalplus/rx-player/issues/1464
13
+ * - (2024-09-04): Another case seen on an "A1" set-top box model made by
14
+ * Kaonmedia we will call the KSTB40xx.
15
+ * It may share the problematic with other devices, but we have only seen
16
+ * the problem on this one for now.
13
17
  *
14
18
  * @returns {boolean}
15
19
  */
16
20
  export default function canReuseMediaKeys() {
17
- return !isWebOs && !isPhilipsNetTv && !isPanasonic;
21
+ return !isWebOs && !isPhilipsNetTv && !isPanasonic && !isA1KStb40xx;
18
22
  }
@@ -17,6 +17,18 @@ export interface ICmcdSegmentInfo {
17
17
  representation: IRepresentation;
18
18
  /** Segment metadata linked to the wanted segment. */
19
19
  segment: ISegment;
20
+ /**
21
+ * Optional next segment that may be requested after this one.
22
+ * Should only be set (to something else than `undefined`) if that following
23
+ * segment is part of the same `Representation`.
24
+ *
25
+ * This information is used to produce the "next object request" and "next
26
+ * range request" part of the CMCD payload, used for segment prefetching.
27
+ *
28
+ * If `null` no segment will be requested next for now.
29
+ * If `undefined` we do not know which next segment will be requested.
30
+ */
31
+ nextSegment: ISegment | null | undefined;
20
32
  }
21
33
  /**
22
34
  * Media playback observation's properties the `CmcdDataBuilder` wants to have
@@ -1 +1 @@
1
- {"version":3,"file":"cmcd_data_builder.d.ts","sourceRoot":"","sources":["../../../../src/core/cmcd/cmcd_data_builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,eAAe,EACf,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAejD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,QAAQ,EAAE,SAAS,CAAC;IACpB,oDAAoD;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,UAAU,EAAE,WAAW,CAAC;IACxB,4DAA4D;IAC5D,cAAc,EAAE,eAAe,CAAC;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EzC;;;;OAIG;gBACS,OAAO,EAAE,YAAY;IAajC;;;;;;;;;OASG;IACI,uBAAuB,CAC5B,gBAAgB,EAAE,yBAAyB,CAAC,mCAAmC,CAAC,GAC/E,IAAI;IAcP;;;OAGG;IACI,sBAAsB,IAAI,IAAI;IAMrC;;;;;;OAMG;IACI,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS;IAI7E;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;;;;OAKG;IACI,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY;IAoBlE;;;;;OAKG;IACI,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY;IAyH5E;;;;;OAKG;IACH,OAAO,CAAC,eAAe;CAoHxB"}
@@ -2,6 +2,7 @@ import log from "../../log";
2
2
  import createUuid from "../../utils/create_uuid";
3
3
  import isNullOrUndefined from "../../utils/is_null_or_undefined";
4
4
  import TaskCanceller from "../../utils/task_canceller";
5
+ import { getRelativeUrl } from "../../utils/url-utils";
5
6
  /**
6
7
  * `rtp`, for "REQUESTED_MAXIMUM_THROUGHPUT", indicates the maximum throughput
7
8
  * needed to load a given segment without experience degration.
@@ -141,7 +142,6 @@ export default class CmcdDataBuilder {
141
142
  const props = this._getCommonCmcdData(this._lastThroughput[content.adaptation.type]);
142
143
  props.br = Math.round(content.representation.bitrate / 1000);
143
144
  props.d = Math.round(content.segment.duration * 1000);
144
- // TODO nor (next object request) and nrr (next range request)
145
145
  switch (content.adaptation.type) {
146
146
  case "video":
147
147
  props.ot = "v";
@@ -156,6 +156,30 @@ export default class CmcdDataBuilder {
156
156
  if (content.segment.isInit) {
157
157
  props.ot = "i";
158
158
  }
159
+ if (!isNullOrUndefined(content.nextSegment) &&
160
+ content.segment.url !== null &&
161
+ content.nextSegment.url !== null) {
162
+ // We add a special case for some initialization segment which need
163
+ // multiple byte-ranges to fully request, as the `CmcdDataBuilder`
164
+ // is not supposed to keep track of how the requesting part of the
165
+ // RxPlayer actually perform its multi-byte-range requests
166
+ if (!content.nextSegment.isInit || content.nextSegment.indexRange === undefined) {
167
+ const currSegmentUrl = content.segment.url;
168
+ const nextSegmentUrl = content.nextSegment.url;
169
+ const relativeUrl = getRelativeUrl(currSegmentUrl, nextSegmentUrl);
170
+ if (relativeUrl !== null) {
171
+ if (relativeUrl !== ".") {
172
+ props.nor = encodeURIComponent(relativeUrl);
173
+ }
174
+ if (content.nextSegment.range !== undefined) {
175
+ props.nrr = String(content.nextSegment.range[0]) + "-";
176
+ if (isFinite(content.nextSegment.range[1])) {
177
+ props.nrr += String(content.nextSegment.range[1]);
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
159
183
  let precizeBufferLengthMs;
160
184
  if (lastObservation !== undefined &&
161
185
  (props.ot === "v" || props.ot === "a" || props.ot === "av")) {
@@ -266,6 +290,8 @@ export default class CmcdDataBuilder {
266
290
  addNumberProperty("d", "object");
267
291
  addNumberProperty("dl", "request");
268
292
  addNumberProperty("mtp", "request");
293
+ addStringProperty("nor", "request");
294
+ addStringProperty("nrr", "request");
269
295
  addTokenProperty("ot", "object");
270
296
  addNumberProperty("pr", "session");
271
297
  addNumberProperty("rtp", "status");
@@ -70,11 +70,35 @@ export interface ISegmentFetcherCallbacks<TSegmentDataType> {
70
70
  }
71
71
  /** Content used by the segment loader as a context to load a new segment. */
72
72
  export interface ISegmentLoaderContent {
73
+ /** Manifest metadata linked to the wanted segment. */
73
74
  manifest: IManifest;
75
+ /** Period metadata linked to the wanted segment. */
74
76
  period: IPeriod;
77
+ /** Adaptation metadata linked to the wanted segment. */
75
78
  adaptation: IAdaptation;
79
+ /** Representation metadata linked to the wanted segment. */
76
80
  representation: IRepresentation;
81
+ /** Segment metadata linked to the wanted segment. */
77
82
  segment: ISegment;
83
+ /**
84
+ * Optional next segment that may be requested after this one.
85
+ * Should only be set (to something else than `undefined`) if that following
86
+ * segment is part of the same `Representation`.
87
+ *
88
+ * This is only used as an hint, finally requesting another segment after this
89
+ * one due to unexpected changes (e.g. bandwidth update, track change etc.) is
90
+ * OK.
91
+ *
92
+ * This information is then used mostly for matters related yet not required
93
+ * by requests, such as CMCD reporting. In scenarios when it's not
94
+ * straightforward to guess which segment will be requested after this one,
95
+ * this property can be ignored (set to `undefined`).
96
+ *
97
+ * If `null` no segment will be requested next for now.
98
+ *
99
+ * If `undefined` we do not know which next segment will be requested.
100
+ */
101
+ nextSegment: ISegment | null | undefined;
78
102
  }
79
103
  /**
80
104
  * Callbacks given when creating an `ISegmentFetcher`, allowing to be notified
@@ -1 +1 @@
1
- {"version":3,"file":"segment_fetcher.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_fetcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAMV,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,+BAA+B,EAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,eAAe,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AAQrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,aAAa,EAAE,gBAAgB,EAAE,EAC5E,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,GACf,EAAE,wBAAwB,C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CAAC;CACpD;AAED,4EAA4E;AAC5E,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,EAC9C,QAAQ,EACR,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,sBAAsB,CAqBzB;AAED,MAAM,WAAW,wBAAwB,CAAC,aAAa,EAAE,gBAAgB;IACvE,0EAA0E;IAC1E,UAAU,EAAE,WAAW,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAC5D;;;;;;;OAOG;IACH,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC;;;OAGG;IACH,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC;;;;;OAKG;IACH,cAAc,EAAE,iCAAiC,CAAC;IAClD;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;CACxC"}
1
+ {"version":3,"file":"segment_fetcher.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_fetcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,O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AC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,sBAAsB,CAqBzB;AAED,MAAM,WAAW,wBAAwB,CAAC,aAAa,EAAE,gBAAgB;IACvE,0EAA0E;IAC1E,UAAU,EAAE,WAAW,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAC5D;;;;;;;OAOG;IACH,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC;;;OAGG;IACH,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC;;;;;OAKG;IACH,cAAc,EAAE,iCAAiC,CAAC;IAClD;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;CACxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"segment_queue.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,6BAA6B,EAC7B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAGxD,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,CAAC,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C,GAAG;IACzE,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AACF,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;OAUG;IACH,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IAEnC;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAcD,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,UAAU,EAAE,WAAW,CAAC;IACxB,wDAAwD;IACxD,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,cAAc,EAAE,eAAe,CAAC;CACjC"}
1
+ {"version":3,"file":"segment_queue.d.ts","sourceRoot":"","sources":["../../../../../src/core/fetchers/segment/segment_queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,6BAA6B,EAC7B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAGxD,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO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zE,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AACF,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;OAUG;IACH,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IAEnC;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAcD,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,UAAU,EAAE,WAAW,CAAC;IACxB,wDAAwD;IACxD,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,cAAc,EAAE,eAAe,CAAC;CACjC"}
@@ -183,9 +183,10 @@ export default class SegmentQueue extends EventEmitter {
183
183
  contentInfo.mediaSegmentRequest.canceller.cancel();
184
184
  }
185
185
  const { downloadQueue, content, initSegmentInfoRef, currentCanceller } = contentInfo;
186
- const { segmentQueue } = downloadQueue.getValue();
187
- const currentNeededSegment = segmentQueue[0];
188
- const recursivelyRequestSegments = (startingSegment) => {
186
+ const recursivelyRequestSegments = () => {
187
+ var _a;
188
+ const { segmentQueue } = downloadQueue.getValue();
189
+ const startingSegment = segmentQueue[0];
189
190
  if (currentCanceller !== null && currentCanceller.isUsed()) {
190
191
  contentInfo.mediaSegmentRequest = null;
191
192
  return;
@@ -200,7 +201,7 @@ export default class SegmentQueue extends EventEmitter {
200
201
  ? noop
201
202
  : canceller.linkToSignal(currentCanceller.signal);
202
203
  const { segment, priority } = startingSegment;
203
- const context = objectAssign({ segment }, content);
204
+ const context = objectAssign({ segment, nextSegment: (_a = segmentQueue[1]) === null || _a === void 0 ? void 0 : _a.segment }, content);
204
205
  /**
205
206
  * If `true` , the current task has either errored, finished, or was
206
207
  * cancelled.
@@ -237,7 +238,7 @@ export default class SegmentQueue extends EventEmitter {
237
238
  lastQueue.shift();
238
239
  }
239
240
  isComplete = true;
240
- recursivelyRequestSegments(lastQueue[0]);
241
+ recursivelyRequestSegments();
241
242
  };
242
243
  /** Scheduled actual segment request. */
243
244
  const request = this._segmentFetcher.createRequest(context, priority, {
@@ -316,7 +317,7 @@ export default class SegmentQueue extends EventEmitter {
316
317
  });
317
318
  contentInfo.mediaSegmentRequest = { segment, priority, request, canceller };
318
319
  };
319
- recursivelyRequestSegments(currentNeededSegment);
320
+ recursivelyRequestSegments();
320
321
  }
321
322
  /**
322
323
  * Internal logic performing initialization segment requests.
@@ -336,7 +337,7 @@ export default class SegmentQueue extends EventEmitter {
336
337
  ? noop
337
338
  : canceller.linkToSignal(contentInfo.currentCanceller.signal);
338
339
  const { segment, priority } = queuedInitSegment;
339
- const context = objectAssign({ segment }, content);
340
+ const context = objectAssign({ segment, nextSegment: undefined }, content);
340
341
  /**
341
342
  * If `true` , the current task has either errored, finished, or was
342
343
  * cancelled.
@@ -670,6 +670,10 @@ function loadOrReloadPreparedContent(val, contentPreparer, playbackObservationRe
670
670
  onCodecSwitch: val.onCodecSwitch,
671
671
  }, contentPreparer, playbackObservationRef, parentCancelSignal);
672
672
  }, (err) => {
673
+ if (TaskCanceller.isCancellationError(err)) {
674
+ log.info("WP: A reloading operation was cancelled");
675
+ return;
676
+ }
673
677
  sendMessage({
674
678
  type: "error" /* WorkerMessageType.Error */,
675
679
  contentId,
@@ -1 +1 @@
1
- {"version":3,"file":"video_thumbnail_loader.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAW5D,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAOtD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;IACjD,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,uBAAuB,CAAiD;gBAEpE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS;IAM7D;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI;IAIhE;;;;;;;;;OASG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiPtC;;;OAGG;IACH,OAAO,IAAI,IAAI;CAMhB;AA+GD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"video_thumbnail_loader.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAW5D,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAOtD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmB;IACjD,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,uBAAuB,CAAiD;gBAEpE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS;IAM7D;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI;IAIhE;;;;;;;;;OASG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuPtC;;;OAGG;IACH,OAAO,IAAI,IAAI;CAMhB;AA+GD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
@@ -149,7 +149,7 @@ export default class VideoThumbnailLoader {
149
149
  lastRepInfo.initSegmentUniqueId = null;
150
150
  return sourceBufferInterface;
151
151
  }
152
- const segmentInfo = objectAssign({ segment: initSegment }, content);
152
+ const segmentInfo = objectAssign({ segment: initSegment, nextSegment: undefined }, content);
153
153
  await loadAndPushSegment(segmentInfo, sourceBufferInterface, lastRepInfo.segmentFetcher, lastRepInfoCleaner.signal);
154
154
  return sourceBufferInterface;
155
155
  });
@@ -193,7 +193,7 @@ export default class VideoThumbnailLoader {
193
193
  else {
194
194
  const requestCanceller = new TaskCanceller();
195
195
  const unlinkSignal = requestCanceller.linkToSignal(lastRepInfo.cleaner.signal);
196
- const segmentInfo = objectAssign({ segment }, content);
196
+ const segmentInfo = objectAssign({ segment, nextSegment: undefined }, content);
197
197
  const prom = loadAndPushSegment(segmentInfo, sourceBufferInterface, lastRepInfo.segmentFetcher, requestCanceller.signal).then(unlinkSignal, (err) => {
198
198
  unlinkSignal();
199
199
  throw err;
@@ -142,7 +142,7 @@ class Player extends EventEmitter {
142
142
  // Workaround to support Firefox autoplay on FF 42.
143
143
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
144
144
  videoElement.preload = "auto";
145
- this.version = /* PLAYER_VERSION */ "4.2.0-dev.2024090500";
145
+ this.version = /* PLAYER_VERSION */ "4.2.0-dev.2024091000";
146
146
  this.log = log;
147
147
  this.state = "STOPPED";
148
148
  this.videoElement = videoElement;
@@ -2456,5 +2456,5 @@ class Player extends EventEmitter {
2456
2456
  * Use of a WeakSet ensure the object is garbage collected if it's not used anymore.
2457
2457
  */
2458
2458
  Player._priv_currentlyUsedVideoElements = new WeakSet();
2459
- Player.version = /* PLAYER_VERSION */ "4.2.0-dev.2024090500";
2459
+ Player.version = /* PLAYER_VERSION */ "4.2.0-dev.2024091000";
2460
2460
  export default Player;
@@ -18,7 +18,7 @@ import log from "../../../../log";
18
18
  import arrayFind from "../../../../utils/array_find";
19
19
  import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
20
20
  import getMonotonicTimeStamp from "../../../../utils/monotonic_timestamp";
21
- import { getFilenameIndexInUrl } from "../../../../utils/resolve_url";
21
+ import { getFilenameIndexInUrl } from "../../../../utils/url-utils";
22
22
  import ContentProtectionParser from "./content_protection_parser";
23
23
  import getClockOffset from "./get_clock_offset";
24
24
  import getHTTPUTCTimingURL from "./get_http_utc-timing_url";
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import resolveURL from "../../../../utils/resolve_url";
16
+ import { resolveURL } from "../../../../utils/url-utils";
17
17
  /**
18
18
  * @param {Array.<string>} currentBaseURLs
19
19
  * @param {Array.<Object>} newBaseUrlsIR
@@ -19,7 +19,7 @@ import { StaticRepresentationIndex } from "../../../manifest/classes";
19
19
  import idGenerator from "../../../utils/id_generator";
20
20
  import isNullOrUndefined from "../../../utils/is_null_or_undefined";
21
21
  import getMonotonicTimeStamp from "../../../utils/monotonic_timestamp";
22
- import { getFilenameIndexInUrl } from "../../../utils/resolve_url";
22
+ import { getFilenameIndexInUrl } from "../../../utils/url-utils";
23
23
  import MetaRepresentationIndex from "./representation_index";
24
24
  /**
25
25
  * Parse playlist string to JSON.
@@ -22,8 +22,8 @@ import isNonEmptyString from "../../../utils/is_non_empty_string";
22
22
  import isNullOrUndefined from "../../../utils/is_null_or_undefined";
23
23
  import getMonotonicTimeStamp from "../../../utils/monotonic_timestamp";
24
24
  import objectAssign from "../../../utils/object_assign";
25
- import { getFilenameIndexInUrl } from "../../../utils/resolve_url";
26
25
  import { hexToBytes } from "../../../utils/string_parsing";
26
+ import { getFilenameIndexInUrl } from "../../../utils/url-utils";
27
27
  import { createBox } from "../../containers/isobmff";
28
28
  import checkManifestIDs from "../utils/check_manifest_ids";
29
29
  import { getAudioCodecs, getVideoCodecs } from "./get_codecs";
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import resolveURL from "../../utils/resolve_url";
16
+ import { resolveURL } from "../../utils/url-utils";
17
17
  export default function constructSegmentUrl(wantedCdn, segment) {
18
18
  if (wantedCdn === null) {
19
19
  return null;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import resolveURL from "../../utils/resolve_url";
16
+ import { resolveURL } from "../../utils/url-utils";
17
17
  /**
18
18
  * Returns `true` if the given Representation refers to segments in an MP4
19
19
  * container
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAI3C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAE7C,KAAK,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9E,KAAK,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,iBAAiB,EAAE,KAAK,IAAI,CAAC;AAIzD;;;GAGG;AACH,UAAU,aAAa;IACrB,gBAAgB,EAAE;QAChB,KAAK,EAAE,YAAY,CAAC;QACpB,MAAM,EAAE,UAAU,CAAC;KACpB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,YAAY,CAAC,aAAa,CAAC;IACtD,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;I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,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IACzB,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;;IAavD;;;;;;;;;OASG;IACI,QAAQ,CACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,CACN,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,KAC9D,IAAI,GACR,IAAI;IA6EP;;;OAGG;IACI,QAAQ,IAAI,YAAY;IAI/B;;;OAGG;IACI,SAAS,IAAI,UAAU;IAI9B;;;;;OAKG;IACI,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO;CAGjD"}
@@ -99,18 +99,17 @@ export default class Logger extends EventEmitter {
99
99
  /* eslint-enable no-invalid-this */
100
100
  }
101
101
  else {
102
- const produceLogFn = (logLevel, namespace) => {
102
+ const produceLogFn = (logLevel) => {
103
103
  return level >= this._levels[logLevel]
104
104
  ? (...args) => {
105
- const now = getMonotonicTimeStamp();
106
- return logFn(logLevel, [now, namespace, ...args]);
105
+ return logFn(logLevel, args);
107
106
  }
108
107
  : noop;
109
108
  };
110
- this.error = produceLogFn("ERROR", "error");
111
- this.warn = produceLogFn("WARNING", "warn");
112
- this.info = produceLogFn("INFO", "info");
113
- this.debug = produceLogFn("DEBUG", "log");
109
+ this.error = produceLogFn("ERROR");
110
+ this.warn = produceLogFn("WARNING");
111
+ this.info = produceLogFn("INFO");
112
+ this.debug = produceLogFn("DEBUG");
114
113
  }
115
114
  this.trigger("onLogLevelChange", {
116
115
  level: this._currentLevel,
@@ -22,6 +22,18 @@
22
22
  * @returns {number}
23
23
  */
24
24
  declare function getFilenameIndexInUrl(url: string): number;
25
+ /**
26
+ * Take two URLs and try to construct a relative URL for the second (`newUrl`)
27
+ * relative to the first (`baseUrl`).
28
+ *
29
+ * Returns `null` if they appear to be on different domains, depend on
30
+ * different schemes or if we don't have enough information to compute the
31
+ * relative URL.
32
+ * @param {string} baseUrl
33
+ * @param {string} newUrl
34
+ * @returns {string}
35
+ */
36
+ declare function getRelativeUrl(baseUrl: string, newUrl: string): string | null;
25
37
  /**
26
38
  * Resolves multiple URL segments using the RFC 3986 URL resolution algorithm.
27
39
  *
@@ -33,7 +45,6 @@ declare function getFilenameIndexInUrl(url: string): number;
33
45
  * @param {...(string|undefined)} args - The URL segments to resolve.
34
46
  * @returns {string} The resolved URL as a string.
35
47
  */
36
- export declare function resolveURL(...args: Array<string | undefined>): string;
37
- export { getFilenameIndexInUrl };
38
- export default resolveURL;
39
- //# sourceMappingURL=resolve_url.d.ts.map
48
+ declare function resolveURL(...args: Array<string | undefined>): string;
49
+ export { getFilenameIndexInUrl, getRelativeUrl, resolveURL };
50
+ //# sourceMappingURL=url-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/url-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuBH;;;;;;;GAOG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAuBlD;AAED;;;;;;;;;;GAUG;AACH,iBAAS,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkEtE;AAsLD;;;;;;;;;;GAUG;AACH,iBAAS,UAAU,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAe9D;AAED,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC"}
@@ -59,6 +59,75 @@ function getFilenameIndexInUrl(url) {
59
59
  }
60
60
  return indexOfLastSlash + 1;
61
61
  }
62
+ /**
63
+ * Take two URLs and try to construct a relative URL for the second (`newUrl`)
64
+ * relative to the first (`baseUrl`).
65
+ *
66
+ * Returns `null` if they appear to be on different domains, depend on
67
+ * different schemes or if we don't have enough information to compute the
68
+ * relative URL.
69
+ * @param {string} baseUrl
70
+ * @param {string} newUrl
71
+ * @returns {string}
72
+ */
73
+ function getRelativeUrl(baseUrl, newUrl) {
74
+ const baseParts = parseURL(baseUrl);
75
+ const newParts = parseURL(newUrl);
76
+ if (baseParts.scheme !== newParts.scheme ||
77
+ baseParts.authority !== newParts.authority) {
78
+ return null;
79
+ }
80
+ if (
81
+ // if base and new path are mixed between absolute and relative path, return null
82
+ (baseParts.path[0] !== undefined &&
83
+ baseParts.path[0] !== "/" &&
84
+ newParts.path[0] === "/") ||
85
+ (newParts.path[0] !== undefined &&
86
+ newParts.path[0] !== "/" &&
87
+ baseParts.path[0] === "/")) {
88
+ return null;
89
+ }
90
+ const baseNormalizedPath = removeDotSegment(baseParts.path);
91
+ const newNormalizedPath = removeDotSegment(newParts.path);
92
+ let relativePath;
93
+ if (baseNormalizedPath === newNormalizedPath) {
94
+ relativePath = "";
95
+ }
96
+ else {
97
+ const basePathSplitted = baseNormalizedPath.split("/");
98
+ // remove everything after the last trailing /
99
+ basePathSplitted.pop();
100
+ const newPathSplitted = newNormalizedPath.split("/");
101
+ while (basePathSplitted.length > 0 &&
102
+ newPathSplitted.length > 0 &&
103
+ basePathSplitted[0] === newPathSplitted[0]) {
104
+ basePathSplitted.shift();
105
+ newPathSplitted.shift();
106
+ }
107
+ while (basePathSplitted.length > 0) {
108
+ basePathSplitted.shift();
109
+ newPathSplitted.unshift("..");
110
+ }
111
+ let pathJoined = newPathSplitted.join("/");
112
+ if (pathJoined.endsWith("../") || pathJoined.endsWith("./")) {
113
+ pathJoined = pathJoined.slice(0, pathJoined.length - 1);
114
+ }
115
+ relativePath = pathJoined === "" ? "." : pathJoined;
116
+ }
117
+ let result = relativePath;
118
+ if (relativePath === "" && newParts.query === baseParts.query) {
119
+ // path and query is the same, we don't need to rewrite it
120
+ }
121
+ else if (newParts.query) {
122
+ result += "?";
123
+ result += newParts.query;
124
+ }
125
+ if (newParts.fragment) {
126
+ result += "#";
127
+ result += newParts.fragment;
128
+ }
129
+ return result;
130
+ }
62
131
  /**
63
132
  * Resolve the output URL from the baseURL and the relative reference as
64
133
  * specified by RFC 3986 section 5.
@@ -232,7 +301,7 @@ function mergePaths(baseParts, relativePath) {
232
301
  * @param {...(string|undefined)} args - The URL segments to resolve.
233
302
  * @returns {string} The resolved URL as a string.
234
303
  */
235
- export function resolveURL(...args) {
304
+ function resolveURL(...args) {
236
305
  var _a, _b, _c;
237
306
  const filteredArgs = args.filter((val) => val !== "");
238
307
  const len = filteredArgs.length;
@@ -250,5 +319,4 @@ export function resolveURL(...args) {
250
319
  return resolveURL(resolvedURL, ...remainingArgs);
251
320
  }
252
321
  }
253
- export { getFilenameIndexInUrl };
254
- export default resolveURL;
322
+ export { getFilenameIndexInUrl, getRelativeUrl, resolveURL };