rx-player 4.3.0-dev.2025031700 → 4.3.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/CHANGELOG.md +9 -1
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +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/add_class_name.d.ts.map +1 -1
- package/dist/commonjs/compat/add_class_name.js +1 -4
- package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.js +0 -1
- package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
- package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.js +0 -2
- package/dist/commonjs/compat/eme/eme-api-implementation.js +0 -1
- package/dist/commonjs/compat/eme/generate_key_request.d.ts +2 -2
- package/dist/commonjs/compat/eme/generate_key_request.js +2 -2
- package/dist/commonjs/compat/is_vtt_cue.d.ts.map +1 -1
- package/dist/commonjs/compat/is_vtt_cue.js +0 -1
- package/dist/commonjs/compat/patch_webkit_source_buffer.js +1 -1
- package/dist/commonjs/core/main/worker/content_preparer.d.ts.map +1 -1
- package/dist/commonjs/core/main/worker/content_preparer.js +82 -0
- package/dist/commonjs/core/segment_sinks/garbage_collector.d.ts.map +1 -1
- package/dist/commonjs/core/segment_sinks/garbage_collector.js +4 -0
- package/dist/commonjs/core/stream/representation/representation_stream.d.ts.map +1 -1
- package/dist/commonjs/core/stream/representation/representation_stream.js +29 -45
- package/dist/commonjs/core/stream/representation/utils/push_init_segment.d.ts.map +1 -1
- package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +0 -3
- package/dist/commonjs/core/stream/representation/utils/push_media_segment.d.ts.map +1 -1
- package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +0 -3
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +2 -2
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.js +2 -2
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +0 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +0 -1
- package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/commonjs/main_thread/api/public_api.js +2 -3
- package/dist/commonjs/main_thread/decrypt/session_events_listener.d.ts.map +1 -1
- package/dist/commonjs/main_thread/decrypt/session_events_listener.js +26 -18
- package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.d.ts +1 -1
- package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.js +1 -1
- package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +5 -3
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts +5 -4
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +10 -4
- package/dist/commonjs/manifest/classes/manifest.js +1 -1
- package/dist/commonjs/manifest/classes/representation.d.ts +2 -0
- package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/representation.js +1 -0
- package/dist/commonjs/manifest/types.d.ts +2 -0
- package/dist/commonjs/manifest/types.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/tokens.js +3 -3
- package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +1 -1
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
- package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
- package/dist/commonjs/parsers/texttracks/ttml/parse_ttml.d.ts +1 -1
- package/dist/commonjs/parsers/texttracks/ttml/regexps.d.ts.map +1 -1
- package/dist/commonjs/parsers/texttracks/ttml/regexps.js +1 -1
- package/dist/commonjs/parsers/texttracks/webvtt/native/set_settings_on_cue.js +1 -1
- package/dist/commonjs/transports/smooth/segment_loader.d.ts.map +1 -1
- package/dist/commonjs/utils/array_find.js +1 -1
- package/dist/commonjs/utils/array_find_index.js +1 -1
- package/dist/commonjs/utils/array_includes.js +1 -1
- package/dist/commonjs/utils/assert.js +1 -1
- package/dist/commonjs/utils/flat_map.d.ts.map +1 -1
- package/dist/commonjs/utils/flat_map.js +0 -1
- package/dist/commonjs/utils/logger.d.ts.map +1 -1
- package/dist/commonjs/utils/logger.js +0 -2
- package/dist/commonjs/utils/noop.js +1 -1
- package/dist/commonjs/utils/object_assign.d.ts.map +1 -1
- package/dist/commonjs/utils/object_assign.js +3 -4
- package/dist/commonjs/utils/object_values.js +1 -1
- package/dist/commonjs/utils/request/xhr.js +1 -1
- package/dist/commonjs/utils/starts_with.d.ts.map +1 -1
- package/dist/commonjs/utils/starts_with.js +0 -1
- package/dist/commonjs/utils/string_parsing.js +1 -1
- package/dist/commonjs/utils/url-utils.js +2 -2
- package/dist/commonjs/utils/weak_map_memory.d.ts.map +1 -1
- package/dist/commonjs/utils/weak_map_memory.js +0 -1
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- 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/add_class_name.d.ts.map +1 -1
- package/dist/es2017/compat/add_class_name.js +1 -4
- package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/es2017/compat/browser_compatibility_types.js +0 -1
- package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
- package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.js +0 -2
- package/dist/es2017/compat/eme/eme-api-implementation.js +0 -1
- package/dist/es2017/compat/eme/generate_key_request.d.ts +2 -2
- package/dist/es2017/compat/eme/generate_key_request.js +2 -2
- package/dist/es2017/compat/is_vtt_cue.d.ts.map +1 -1
- package/dist/es2017/compat/is_vtt_cue.js +0 -1
- package/dist/es2017/compat/patch_webkit_source_buffer.js +1 -1
- package/dist/es2017/core/main/worker/content_preparer.d.ts.map +1 -1
- package/dist/es2017/core/main/worker/content_preparer.js +34 -0
- package/dist/es2017/core/segment_sinks/garbage_collector.d.ts.map +1 -1
- package/dist/es2017/core/segment_sinks/garbage_collector.js +4 -0
- package/dist/es2017/core/stream/representation/representation_stream.d.ts.map +1 -1
- package/dist/es2017/core/stream/representation/representation_stream.js +29 -45
- package/dist/es2017/core/stream/representation/utils/push_init_segment.d.ts.map +1 -1
- package/dist/es2017/core/stream/representation/utils/push_init_segment.js +0 -3
- package/dist/es2017/core/stream/representation/utils/push_media_segment.d.ts.map +1 -1
- package/dist/es2017/core/stream/representation/utils/push_media_segment.js +0 -3
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +2 -2
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.js +2 -2
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +0 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +0 -1
- package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
- package/dist/es2017/main_thread/api/public_api.js +2 -3
- package/dist/es2017/main_thread/decrypt/session_events_listener.d.ts.map +1 -1
- package/dist/es2017/main_thread/decrypt/session_events_listener.js +4 -6
- package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.d.ts +1 -1
- package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.js +1 -1
- package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +5 -3
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts +5 -4
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +10 -4
- package/dist/es2017/manifest/classes/manifest.js +1 -1
- package/dist/es2017/manifest/classes/representation.d.ts +2 -0
- package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/representation.js +1 -0
- package/dist/es2017/manifest/types.d.ts +2 -0
- package/dist/es2017/manifest/types.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/tokens.js +3 -3
- package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +1 -1
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
- package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
- package/dist/es2017/parsers/texttracks/ttml/parse_ttml.d.ts +1 -1
- package/dist/es2017/parsers/texttracks/ttml/regexps.d.ts.map +1 -1
- package/dist/es2017/parsers/texttracks/ttml/regexps.js +1 -1
- package/dist/es2017/parsers/texttracks/webvtt/native/set_settings_on_cue.js +1 -1
- package/dist/es2017/transports/smooth/segment_loader.d.ts.map +1 -1
- package/dist/es2017/utils/array_find.js +1 -1
- package/dist/es2017/utils/array_find_index.js +1 -1
- package/dist/es2017/utils/array_includes.js +1 -1
- package/dist/es2017/utils/assert.js +1 -1
- package/dist/es2017/utils/flat_map.d.ts.map +1 -1
- package/dist/es2017/utils/flat_map.js +0 -1
- package/dist/es2017/utils/logger.d.ts.map +1 -1
- package/dist/es2017/utils/logger.js +0 -2
- package/dist/es2017/utils/noop.js +1 -1
- package/dist/es2017/utils/object_assign.d.ts.map +1 -1
- package/dist/es2017/utils/object_assign.js +3 -4
- package/dist/es2017/utils/object_values.js +1 -1
- package/dist/es2017/utils/request/xhr.js +1 -1
- package/dist/es2017/utils/starts_with.d.ts.map +1 -1
- package/dist/es2017/utils/starts_with.js +0 -1
- package/dist/es2017/utils/string_parsing.js +1 -1
- package/dist/es2017/utils/url-utils.js +2 -2
- package/dist/es2017/utils/weak_map_memory.d.ts.map +1 -1
- package/dist/es2017/utils/weak_map_memory.js +0 -1
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +80 -107
- package/dist/rx-player.min.js +13 -13
- package/dist/worker.js +4 -4
- package/eslint.config.mjs +423 -0
- package/package.json +25 -20
- package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/should_wait_for_data_before_loaded.test.ts +0 -1
- package/src/compat/add_class_name.ts +1 -4
- package/src/compat/browser_compatibility_types.ts +0 -1
- package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +0 -2
- package/src/compat/eme/eme-api-implementation.ts +0 -1
- package/src/compat/eme/generate_key_request.ts +2 -2
- package/src/compat/is_vtt_cue.ts +0 -1
- package/src/compat/patch_webkit_source_buffer.ts +1 -1
- package/src/core/main/worker/content_preparer.ts +35 -1
- package/src/core/segment_sinks/garbage_collector.ts +4 -0
- package/src/core/stream/representation/representation_stream.ts +29 -64
- package/src/core/stream/representation/utils/push_init_segment.ts +0 -3
- package/src/core/stream/representation/utils/push_media_segment.ts +0 -3
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +0 -3
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +0 -2
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/decodingInfos.test.ts +0 -2
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaContentType.test.ts +0 -2
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +0 -7
- package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
- package/src/experimental/tools/mediaCapabilitiesProber/capabilities.ts +2 -2
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +0 -1
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +0 -1
- package/src/main_thread/api/public_api.ts +2 -3
- package/src/main_thread/decrypt/session_events_listener.ts +9 -8
- package/src/main_thread/decrypt/utils/loaded_sessions_store.ts +1 -1
- package/src/main_thread/init/multi_thread_content_initializer.ts +5 -2
- package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +45 -2
- package/src/main_thread/init/utils/update_manifest_codec_support.ts +13 -3
- package/src/manifest/classes/manifest.ts +1 -1
- package/src/manifest/classes/representation.ts +3 -0
- package/src/manifest/types.ts +2 -0
- package/src/parsers/manifest/dash/common/convert_supplemental_codecs.ts +1 -1
- package/src/parsers/manifest/dash/common/indexes/tokens.ts +3 -3
- package/src/parsers/manifest/dash/common/parse_representations.ts +1 -1
- package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/AdaptationSet.test.ts +3 -7
- package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentComponent.test.ts +1 -1
- package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentProtection.test.ts +1 -1
- package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/AdaptationSet.test.ts +3 -3
- package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentComponent.test.ts +1 -1
- package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentProtection.test.ts +2 -2
- package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
- package/src/parsers/texttracks/ttml/regexps.ts +1 -1
- package/src/parsers/texttracks/webvtt/native/set_settings_on_cue.ts +1 -1
- package/src/utils/__tests__/array_find.test.ts +1 -1
- package/src/utils/__tests__/array_find_index.test.ts +0 -1
- package/src/utils/__tests__/array_includes.test.ts +1 -1
- package/src/utils/__tests__/id_generator.test.ts +0 -2
- package/src/utils/array_find.ts +1 -1
- package/src/utils/array_find_index.ts +1 -1
- package/src/utils/array_includes.ts +1 -1
- package/src/utils/assert.ts +1 -1
- package/src/utils/flat_map.ts +0 -1
- package/src/utils/logger.ts +0 -2
- package/src/utils/noop.ts +1 -1
- package/src/utils/object_assign.ts +3 -4
- package/src/utils/object_values.ts +1 -1
- package/src/utils/request/xhr.ts +2 -2
- package/src/utils/starts_with.ts +0 -1
- package/src/utils/string_parsing.ts +1 -1
- package/src/utils/url-utils.ts +2 -2
- package/src/utils/weak_map_memory.ts +0 -1
- package/vitest.config.mjs +34 -28
|
@@ -111,23 +111,23 @@ export default function SessionEventsListener(
|
|
|
111
111
|
() => runGetLicense(message, messageType),
|
|
112
112
|
backoffOptions,
|
|
113
113
|
manualCanceller.signal,
|
|
114
|
-
)
|
|
115
|
-
|
|
114
|
+
).then(
|
|
115
|
+
async (licenseObject) => {
|
|
116
116
|
if (manualCanceller.isUsed()) {
|
|
117
|
-
return
|
|
117
|
+
return;
|
|
118
118
|
}
|
|
119
119
|
if (isNullOrUndefined(licenseObject)) {
|
|
120
120
|
log.info("DRM: No license given, skipping session.update");
|
|
121
121
|
} else {
|
|
122
122
|
try {
|
|
123
|
-
|
|
123
|
+
await updateSessionWithMessage(session, licenseObject);
|
|
124
124
|
} catch (err) {
|
|
125
125
|
manualCanceller.cancel();
|
|
126
126
|
callbacks.onError(err);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
}
|
|
130
|
-
|
|
129
|
+
},
|
|
130
|
+
(err: unknown) => {
|
|
131
131
|
if (manualCanceller.isUsed()) {
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
@@ -148,7 +148,8 @@ export default function SessionEventsListener(
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
callbacks.onError(formattedError);
|
|
151
|
-
}
|
|
151
|
+
},
|
|
152
|
+
);
|
|
152
153
|
},
|
|
153
154
|
manualCanceller.signal,
|
|
154
155
|
);
|
|
@@ -248,7 +249,7 @@ export interface ISessionEventListenerCallbacks {
|
|
|
248
249
|
*/
|
|
249
250
|
onKeyUpdate: (val: IKeyUpdateValue) => void;
|
|
250
251
|
onWarning: (val: IPlayerError) => void;
|
|
251
|
-
|
|
252
|
+
/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */
|
|
252
253
|
onError: (val: unknown | BlacklistedSessionError) => void;
|
|
253
254
|
}
|
|
254
255
|
|
|
@@ -149,7 +149,7 @@ export default class LoadedSessionsStore {
|
|
|
149
149
|
* @param {Object} mediaKeySession
|
|
150
150
|
* @param {string|undefined} initializationDataType - Initialization data type
|
|
151
151
|
* given e.g. by the "encrypted" event for the corresponding request.
|
|
152
|
-
* @param {Uint8Array}
|
|
152
|
+
* @param {Uint8Array} initializationData - Initialization data given e.g. by
|
|
153
153
|
* the "encrypted" event for the corresponding request.
|
|
154
154
|
* @returns {Promise}
|
|
155
155
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IMediaElement } from "../../compat/browser_compatibility_types";
|
|
2
|
+
import hasMseInWorker from "../../compat/has_mse_in_worker";
|
|
2
3
|
import mayMediaElementFailOnUndecipherableData from "../../compat/may_media_element_fail_on_undecipherable_data";
|
|
3
4
|
import shouldReloadMediaSourceOnDecipherabilityUpdate from "../../compat/should_reload_media_source_on_decipherability_update";
|
|
4
5
|
import type { ISegmentSinkMetrics } from "../../core/segment_sinks/segment_sinks_store";
|
|
@@ -1168,7 +1169,7 @@ export default class MultiThreadContentInitializer extends ContentInitializer {
|
|
|
1168
1169
|
case WorkerMessageType.LogMessage:
|
|
1169
1170
|
// Already handled by prepare's handler
|
|
1170
1171
|
break;
|
|
1171
|
-
case WorkerMessageType.ThumbnailDataResponse:
|
|
1172
|
+
case WorkerMessageType.ThumbnailDataResponse: {
|
|
1172
1173
|
if (this._currentContentInfo?.contentId !== msgData.contentId) {
|
|
1173
1174
|
return;
|
|
1174
1175
|
}
|
|
@@ -1185,6 +1186,7 @@ export default class MultiThreadContentInitializer extends ContentInitializer {
|
|
|
1185
1186
|
log.error("MTCI: Failed to send segment sink store update");
|
|
1186
1187
|
}
|
|
1187
1188
|
break;
|
|
1189
|
+
}
|
|
1188
1190
|
default:
|
|
1189
1191
|
assertUnreachable(msgData);
|
|
1190
1192
|
}
|
|
@@ -1411,6 +1413,7 @@ export default class MultiThreadContentInitializer extends ContentInitializer {
|
|
|
1411
1413
|
const updatedCodecs = updateManifestCodecSupport(
|
|
1412
1414
|
manifest,
|
|
1413
1415
|
this._currentContentInfo?.contentDecryptor ?? null,
|
|
1416
|
+
hasMseInWorker,
|
|
1414
1417
|
);
|
|
1415
1418
|
if (updatedCodecs.length > 0) {
|
|
1416
1419
|
sendMessage(this._settings.worker, {
|
|
@@ -2074,7 +2077,7 @@ function bindNumberReferencesToWorker(
|
|
|
2074
2077
|
// overload, but the body here is not aware of that.
|
|
2075
2078
|
sendMessage(worker, {
|
|
2076
2079
|
type: MainThreadMessageType.ReferenceUpdate,
|
|
2077
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
2080
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
2078
2081
|
value: { name: ref[1] as any, newVal: newVal as any },
|
|
2079
2082
|
});
|
|
2080
2083
|
},
|
|
@@ -47,6 +47,7 @@ function generateFakeManifestWithRepresentations(
|
|
|
47
47
|
id: "period1",
|
|
48
48
|
start: 0,
|
|
49
49
|
streamEvents: [],
|
|
50
|
+
thumbnailTracks: [],
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const manifest: IManifestMetadata = {
|
|
@@ -192,7 +193,7 @@ describe("init - utils - updateManifestCodecSupport", () => {
|
|
|
192
193
|
},
|
|
193
194
|
};
|
|
194
195
|
const contentDecryptor = new ContentDecryptor(video, [keySystem1]);
|
|
195
|
-
updateManifestCodecSupport(manifest, contentDecryptor);
|
|
196
|
+
updateManifestCodecSupport(manifest, contentDecryptor, true);
|
|
196
197
|
expect(representationAVC.isSupported).toBe(true);
|
|
197
198
|
expect(representationHEVC.isSupported).toBe(true);
|
|
198
199
|
expect(representationVP9.isSupported).toBe(false); // Not Supported by MSE
|
|
@@ -273,11 +274,53 @@ describe("init - utils - updateManifestCodecSupport", () => {
|
|
|
273
274
|
const contentDecryptor = new ContentDecryptor(video, [keySystem1]);
|
|
274
275
|
await sleep(100);
|
|
275
276
|
contentDecryptor.attach();
|
|
276
|
-
updateManifestCodecSupport(manifest, contentDecryptor);
|
|
277
|
+
updateManifestCodecSupport(manifest, contentDecryptor, true);
|
|
277
278
|
expect(encryptedRepresentationAVC.isSupported).toBe(true);
|
|
278
279
|
expect(encryptedRepresentationHEVC.isSupported).toBe(false); // Not supported by EME
|
|
279
280
|
expect(encryptedRepresentationVP9.isSupported).toBe(false); // Not supported by MSE
|
|
280
281
|
expect(encryptedRepresentationMP4A.isSupported).toBe(true);
|
|
281
282
|
expect(encryptedRepresentationEC3.isSupported).toBe(false); // Not supported by EME
|
|
282
283
|
});
|
|
284
|
+
|
|
285
|
+
it("should update to false if the codec is not usable with MSE in worker", () => {
|
|
286
|
+
const representationAVC: IRepresentationMetadata = {
|
|
287
|
+
bitrate: 1000,
|
|
288
|
+
id: "representation1",
|
|
289
|
+
uniqueId: "representation1",
|
|
290
|
+
codecs: ["avc1.4d401e"],
|
|
291
|
+
mimeType: "video/mp4",
|
|
292
|
+
isSupported: undefined,
|
|
293
|
+
isCodecSupportedInWebWorker: undefined,
|
|
294
|
+
};
|
|
295
|
+
const representationHEVC: IRepresentationMetadata = {
|
|
296
|
+
bitrate: 2000,
|
|
297
|
+
id: "representation2",
|
|
298
|
+
uniqueId: "representation2",
|
|
299
|
+
codecs: ["hvc1.2.4.L153.B0"],
|
|
300
|
+
mimeType: "video/mp4",
|
|
301
|
+
isSupported: undefined,
|
|
302
|
+
isCodecSupportedInWebWorker: false,
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const representationMP4A: IRepresentationMetadata = {
|
|
306
|
+
bitrate: 1000,
|
|
307
|
+
id: "representation4",
|
|
308
|
+
uniqueId: "representation4",
|
|
309
|
+
codecs: ["mp4a.40.2"],
|
|
310
|
+
mimeType: "audio/mp4",
|
|
311
|
+
isSupported: undefined,
|
|
312
|
+
isCodecSupportedInWebWorker: true,
|
|
313
|
+
};
|
|
314
|
+
const manifest = generateFakeManifestWithRepresentations(
|
|
315
|
+
[representationAVC, representationHEVC],
|
|
316
|
+
[representationMP4A],
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
const video = document.createElement("video");
|
|
320
|
+
const contentDecryptor = new ContentDecryptor(video, []);
|
|
321
|
+
updateManifestCodecSupport(manifest, contentDecryptor, true);
|
|
322
|
+
expect(representationAVC.isSupported).toBe(true);
|
|
323
|
+
expect(representationHEVC.isSupported).toBe(false); // not supported with MSE in worker
|
|
324
|
+
expect(representationMP4A.isSupported).toBe(true);
|
|
325
|
+
});
|
|
283
326
|
});
|
|
@@ -56,13 +56,15 @@ export function getCodecsWithUnknownSupport(
|
|
|
56
56
|
* Because probing for codec support is always synchronous in the main thread,
|
|
57
57
|
* calling this function ensures that support is now known.
|
|
58
58
|
*
|
|
59
|
-
* @param {Object} manifest
|
|
60
|
-
* @param {Object|null} contentDecryptor
|
|
61
|
-
* @
|
|
59
|
+
* @param {Object} manifest - The manifest to update
|
|
60
|
+
* @param {Object|null} contentDecryptor - The current content decryptor
|
|
61
|
+
* @param {boolean} isPlayingWithMSEinWorker - True if WebWorker is used with MSE in worker
|
|
62
|
+
* @returns {Array.<Object>}
|
|
62
63
|
*/
|
|
63
64
|
export function updateManifestCodecSupport(
|
|
64
65
|
manifest: IManifestMetadata,
|
|
65
66
|
contentDecryptor: ContentDecryptor | null,
|
|
67
|
+
isPlayingWithMSEinWorker: boolean,
|
|
66
68
|
): ICodecSupportInfo[] {
|
|
67
69
|
const codecSupportMap: Map<
|
|
68
70
|
string,
|
|
@@ -131,6 +133,14 @@ export function updateManifestCodecSupport(
|
|
|
131
133
|
let hasSupportedCodec: boolean = false;
|
|
132
134
|
let hasCodecWithUndefinedSupport: boolean = false;
|
|
133
135
|
adaptation.representations.forEach((representation) => {
|
|
136
|
+
if (
|
|
137
|
+
representation.isCodecSupportedInWebWorker === false &&
|
|
138
|
+
isPlayingWithMSEinWorker
|
|
139
|
+
) {
|
|
140
|
+
representation.isSupported = false;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
if (representation.isSupported !== undefined) {
|
|
135
145
|
if (representation.isSupported) {
|
|
136
146
|
hasSupportedCodec = true;
|
|
@@ -601,7 +601,7 @@ export default class Manifest
|
|
|
601
601
|
const adaptationsByType = firstPeriod.adaptations;
|
|
602
602
|
const adaptationsList: Adaptation[] = [];
|
|
603
603
|
for (const adaptationType in adaptationsByType) {
|
|
604
|
-
if (
|
|
604
|
+
if (Object.prototype.hasOwnProperty.call(adaptationsByType, adaptationType)) {
|
|
605
605
|
const adaptations = adaptationsByType[
|
|
606
606
|
adaptationType as ITrackType
|
|
607
607
|
] as Adaptation[];
|
|
@@ -121,6 +121,8 @@ class Representation implements IRepresentationMetadata {
|
|
|
121
121
|
* `Manifest` methods for this.
|
|
122
122
|
*/
|
|
123
123
|
public shouldBeAvoided: boolean;
|
|
124
|
+
/** If the codec is supported with MSE in worker */
|
|
125
|
+
public isCodecSupportedInWebWorker: boolean | undefined;
|
|
124
126
|
|
|
125
127
|
/**
|
|
126
128
|
* @param {Object} args
|
|
@@ -484,6 +486,7 @@ class Representation implements IRepresentationMetadata {
|
|
|
484
486
|
hdrInfo: this.hdrInfo,
|
|
485
487
|
contentProtections: this.contentProtections,
|
|
486
488
|
decipherable: this.decipherable,
|
|
489
|
+
isCodecSupportedInWebWorker: this.isCodecSupportedInWebWorker,
|
|
487
490
|
};
|
|
488
491
|
}
|
|
489
492
|
}
|
package/src/manifest/types.ts
CHANGED
|
@@ -488,4 +488,6 @@ export interface IRepresentationMetadata {
|
|
|
488
488
|
decipherable?: boolean | undefined;
|
|
489
489
|
/** Encryption information for this Representation. */
|
|
490
490
|
contentProtections?: IContentProtections | undefined;
|
|
491
|
+
/** If the codec is supported with MSE in worker */
|
|
492
|
+
isCodecSupportedInWebWorker?: boolean | undefined;
|
|
491
493
|
}
|
|
@@ -15,7 +15,7 @@ const supplementalCodecSeparator = /[, ]+/g;
|
|
|
15
15
|
* to be compliant with what MSE APIs expect
|
|
16
16
|
*
|
|
17
17
|
* @param {string} val - The codec string to parse
|
|
18
|
-
* @returns { Array.<string |
|
|
18
|
+
* @returns { Array.<string | undefined | null>}
|
|
19
19
|
*/
|
|
20
20
|
export function convertSupplementalCodecsToRFC6381(val: string): string {
|
|
21
21
|
if (isNonEmptyString(val)) {
|
|
@@ -78,7 +78,7 @@ export function replaceRepresentationDASHTokens(
|
|
|
78
78
|
.replace(/\$\$/g, "$")
|
|
79
79
|
.replace(/\$RepresentationID\$/g, String(id))
|
|
80
80
|
.replace(
|
|
81
|
-
/\$Bandwidth(
|
|
81
|
+
/\$Bandwidth(%0(\d+)d)?\$/g,
|
|
82
82
|
processFormatedToken(bitrate === undefined ? 0 : bitrate),
|
|
83
83
|
);
|
|
84
84
|
}
|
|
@@ -110,13 +110,13 @@ export function createDashUrlDetokenizer(
|
|
|
110
110
|
} else {
|
|
111
111
|
return url
|
|
112
112
|
.replace(/\$\$/g, "$")
|
|
113
|
-
.replace(/\$Number(
|
|
113
|
+
.replace(/\$Number(%0(\d+)d)?\$/g, (_x, _y, widthStr: string) => {
|
|
114
114
|
if (nb === undefined) {
|
|
115
115
|
throw new Error("Segment number not defined in a $Number$ scheme");
|
|
116
116
|
}
|
|
117
117
|
return processFormatedToken(nb)(_x, _y, widthStr);
|
|
118
118
|
})
|
|
119
|
-
.replace(/\$Time(
|
|
119
|
+
.replace(/\$Time(%0(\d+)d)?\$/g, (_x, _y, widthStr: string) => {
|
|
120
120
|
if (time === undefined) {
|
|
121
121
|
throw new Error("Segment time not defined in a $Time$ scheme");
|
|
122
122
|
}
|
|
@@ -37,7 +37,7 @@ import resolveBaseURLs from "./resolve_base_urls";
|
|
|
37
37
|
* adaptation data.
|
|
38
38
|
* @param {Object} representation
|
|
39
39
|
* @param {Object} adaptation
|
|
40
|
-
* @returns {undefined |
|
|
40
|
+
* @returns {undefined | Array.<Object>}
|
|
41
41
|
*/
|
|
42
42
|
function combineInbandEventStreams(
|
|
43
43
|
representation: IRepresentationIntermediateRepresentation,
|
package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/AdaptationSet.test.ts
CHANGED
|
@@ -19,9 +19,7 @@ function testBooleanAttribute(attributeName: string, variableName?: string): voi
|
|
|
19
19
|
[],
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
|
-
const element2 = parseXml(
|
|
23
|
-
`<AdaptationSet ${attributeName}=\"false\" />`,
|
|
24
|
-
)[0] as ITNode;
|
|
22
|
+
const element2 = parseXml(`<AdaptationSet ${attributeName}="false" />`)[0] as ITNode;
|
|
25
23
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
|
26
24
|
{
|
|
27
25
|
attributes: { [_variableName]: false },
|
|
@@ -81,7 +79,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
81
79
|
[],
|
|
82
80
|
]);
|
|
83
81
|
|
|
84
|
-
const element2 = parseXml(`<AdaptationSet ${attributeName}
|
|
82
|
+
const element2 = parseXml(`<AdaptationSet ${attributeName}="" />`)[0] as ITNode;
|
|
85
83
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
|
86
84
|
{
|
|
87
85
|
attributes: { [_variableName]: "" },
|
|
@@ -407,9 +405,7 @@ function testNumberOrBooleanAttribute(
|
|
|
407
405
|
[],
|
|
408
406
|
]);
|
|
409
407
|
|
|
410
|
-
const element2 = parseXml(
|
|
411
|
-
`<AdaptationSet ${attributeName}=\"false\" />`,
|
|
412
|
-
)[0] as ITNode;
|
|
408
|
+
const element2 = parseXml(`<AdaptationSet ${attributeName}="false" />`)[0] as ITNode;
|
|
413
409
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
|
414
410
|
{
|
|
415
411
|
attributes: { [_variableName]: false },
|
package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentComponent.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
14
14
|
[_variableName]: "foobar",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const element2 = parseXml(`<contentComponent ${attributeName}
|
|
17
|
+
const element2 = parseXml(`<contentComponent ${attributeName}="" />`)[0] as ITNode;
|
|
18
18
|
expect(parseContentComponent(element2)).toEqual({ [_variableName]: "" });
|
|
19
19
|
});
|
|
20
20
|
}
|
package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentProtection.test.ts
CHANGED
|
@@ -17,7 +17,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
17
17
|
[],
|
|
18
18
|
]);
|
|
19
19
|
|
|
20
|
-
const element2 = parseXml(`<ContentProtection ${attributeName}
|
|
20
|
+
const element2 = parseXml(`<ContentProtection ${attributeName}="" />`)[0] as ITNode;
|
|
21
21
|
expect(parseContentProtection(element2)).toEqual([
|
|
22
22
|
{ attributes: { [_variableName]: "" }, children: { cencPssh: [] } },
|
|
23
23
|
[],
|
package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/AdaptationSet.test.ts
CHANGED
|
@@ -21,7 +21,7 @@ function testBooleanAttribute(attributeName: string, variableName?: string): voi
|
|
|
21
21
|
]);
|
|
22
22
|
|
|
23
23
|
const element2 = new DOMParser().parseFromString(
|
|
24
|
-
`<AdaptationSet ${attributeName}
|
|
24
|
+
`<AdaptationSet ${attributeName}="false" />`,
|
|
25
25
|
"text/xml",
|
|
26
26
|
).childNodes[0] as Element;
|
|
27
27
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
|
@@ -93,7 +93,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
93
93
|
]);
|
|
94
94
|
|
|
95
95
|
const element2 = new DOMParser().parseFromString(
|
|
96
|
-
`<AdaptationSet ${attributeName}
|
|
96
|
+
`<AdaptationSet ${attributeName}="" />`,
|
|
97
97
|
"text/xml",
|
|
98
98
|
).childNodes[0] as Element;
|
|
99
99
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
|
@@ -497,7 +497,7 @@ function testNumberOrBooleanAttribute(
|
|
|
497
497
|
]);
|
|
498
498
|
|
|
499
499
|
const element2 = new DOMParser().parseFromString(
|
|
500
|
-
`<AdaptationSet ${attributeName}
|
|
500
|
+
`<AdaptationSet ${attributeName}="false" />`,
|
|
501
501
|
"text/xml",
|
|
502
502
|
).childNodes[0] as Element;
|
|
503
503
|
expect(createAdaptationSetIntermediateRepresentation(element2)).toEqual([
|
package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentComponent.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const element2 = new DOMParser().parseFromString(
|
|
17
|
-
`<contentComponent ${attributeName}
|
|
17
|
+
`<contentComponent ${attributeName}="" />`,
|
|
18
18
|
"text/xml",
|
|
19
19
|
).childNodes[0] as Element;
|
|
20
20
|
expect(parseContentComponent(element2)).toEqual({ [_variableName]: "" });
|
package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentProtection.test.ts
CHANGED
|
@@ -17,7 +17,7 @@ function testStringAttribute(attributeName: string, variableName?: string): void
|
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
19
|
const element2 = new DOMParser().parseFromString(
|
|
20
|
-
`<ContentProtection ${attributeName}
|
|
20
|
+
`<ContentProtection ${attributeName}="" />`,
|
|
21
21
|
"text/xml",
|
|
22
22
|
).childNodes[0] as Element;
|
|
23
23
|
expect(parseContentProtection(element2)).toEqual([
|
|
@@ -66,7 +66,7 @@ describe("DASH Node Parsers - ContentProtection", () => {
|
|
|
66
66
|
xmlns:cenc="urn:mpeg:cenc:2013"
|
|
67
67
|
xmlns:mspr="urn:microsoft:playready"
|
|
68
68
|
xmlns:scte35="urn:scte:scte35:2014:xml+bin">
|
|
69
|
-
<ContentProtection cenc:default_KID
|
|
69
|
+
<ContentProtection cenc:default_KID="dead-beef" />
|
|
70
70
|
</MPD>
|
|
71
71
|
`,
|
|
72
72
|
"text/xml",
|
|
@@ -36,7 +36,7 @@ const REGXP_TIME_HMS =
|
|
|
36
36
|
// examples: 50% 10%
|
|
37
37
|
const REGXP_PERCENT_VALUES = /^(\d{1,2}|100)% (\d{1,2}|100)%$/;
|
|
38
38
|
|
|
39
|
-
const REGXP_LENGTH = /^((
|
|
39
|
+
const REGXP_LENGTH = /^((?:\+|-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/;
|
|
40
40
|
|
|
41
41
|
const REGXP_8_HEX_COLOR = /^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/;
|
|
42
42
|
const REGXP_4_HEX_COLOR = /^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/;
|
|
@@ -69,7 +69,7 @@ export default function setSettingsOnCue(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (isNonEmptyString(settings.position)) {
|
|
72
|
-
const positionRegex = /^([\d
|
|
72
|
+
const positionRegex = /^([\d.]+)%(?:,(line-left|line-right|center))?$/;
|
|
73
73
|
const positionArr = positionRegex.exec(settings.position);
|
|
74
74
|
if (Array.isArray(positionArr) && positionArr.length >= 2) {
|
|
75
75
|
const position = parseInt(positionArr[1], 10);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, beforeEach, afterEach, it, expect, vi } from "vitest";
|
|
2
2
|
import arrayFind from "../array_find";
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line no-restricted-properties
|
|
4
|
+
// eslint-disable-next-line no-restricted-properties
|
|
5
5
|
const initialArrayFind = Array.prototype.find;
|
|
6
6
|
|
|
7
7
|
describe("utils - arrayFind", () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, beforeEach, afterEach, it, expect, vi } from "vitest";
|
|
2
2
|
import arrayFindIndex from "../array_find_index";
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
5
4
|
// eslint-disable-next-line no-restricted-properties
|
|
6
5
|
const initialArrayFindIndex = Array.prototype.findIndex;
|
|
7
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, beforeEach, afterEach, it, expect } from "vitest";
|
|
2
2
|
import arrayIncludes from "../array_includes";
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line no-restricted-properties
|
|
4
|
+
// eslint-disable-next-line no-restricted-properties
|
|
5
5
|
const initialArrayIncludes = Array.prototype.includes;
|
|
6
6
|
|
|
7
7
|
describe("utils - array-includes", () => {
|
|
@@ -2,8 +2,6 @@ import { describe, afterEach, it, expect } from "vitest";
|
|
|
2
2
|
import globalScope from "../global_scope";
|
|
3
3
|
import idGenerator from "../id_generator";
|
|
4
4
|
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
6
|
-
|
|
7
5
|
const oldNumberDef = globalScope.Number;
|
|
8
6
|
|
|
9
7
|
describe("utils - idGenerator", () => {
|
package/src/utils/array_find.ts
CHANGED
|
@@ -31,7 +31,7 @@ export default function arrayFind<T>(
|
|
|
31
31
|
predicate: (arg: T, index: number, fullArray: T[]) => boolean,
|
|
32
32
|
thisArg?: unknown,
|
|
33
33
|
): T | undefined {
|
|
34
|
-
// eslint-disable-next-line no-restricted-properties
|
|
34
|
+
// eslint-disable-next-line no-restricted-properties
|
|
35
35
|
if (typeof (Array.prototype as ArrayWithFind<T>).find === "function") {
|
|
36
36
|
// eslint-disable-next-line no-restricted-properties
|
|
37
37
|
return (arr as ArrayWithFind<T>).find(predicate, thisArg);
|
|
@@ -34,7 +34,7 @@ export default function arrayFindIndex<T>(
|
|
|
34
34
|
predicate: (arg: T, index: number, fullArray: T[]) => boolean,
|
|
35
35
|
thisArg?: unknown,
|
|
36
36
|
): number {
|
|
37
|
-
// eslint-disable-next-line no-restricted-properties
|
|
37
|
+
// eslint-disable-next-line no-restricted-properties
|
|
38
38
|
if (typeof (Array.prototype as ArrayWithFindIndex<T>).findIndex === "function") {
|
|
39
39
|
// eslint-disable-next-line no-restricted-properties
|
|
40
40
|
return (arr as ArrayWithFindIndex<T>).findIndex(predicate, thisArg);
|
|
@@ -56,7 +56,7 @@ export default function arrayIncludes<T>(
|
|
|
56
56
|
searchElement: T,
|
|
57
57
|
fromIndex?: number,
|
|
58
58
|
): boolean {
|
|
59
|
-
// eslint-disable-next-line no-restricted-properties
|
|
59
|
+
// eslint-disable-next-line no-restricted-properties
|
|
60
60
|
if (typeof Array.prototype.includes === "function") {
|
|
61
61
|
// eslint-disable-next-line no-restricted-properties
|
|
62
62
|
return arr.includes(searchElement, fromIndex);
|
package/src/utils/assert.ts
CHANGED
|
@@ -72,7 +72,7 @@ export function assertInterface<T>(
|
|
|
72
72
|
): void {
|
|
73
73
|
assert(!isNullOrUndefined(o), `${name} should be an object`);
|
|
74
74
|
for (const k in iface) {
|
|
75
|
-
if (
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(iface, k)) {
|
|
76
76
|
assert(
|
|
77
77
|
typeof o[k] === iface[k],
|
|
78
78
|
`${name} should have property ${k} as a ${iface[k]}`,
|
package/src/utils/flat_map.ts
CHANGED
|
@@ -29,7 +29,6 @@ type ArrayWithFlatMap<T> = T[] & {
|
|
|
29
29
|
* @param {Function} fn
|
|
30
30
|
*/
|
|
31
31
|
export default function flatMap<T, U>(originalArray: T[], fn: (arg: T) => U[] | U): U[] {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
33
32
|
if (typeof (Array.prototype as ArrayWithFlatMap<T>).flatMap === "function") {
|
|
34
33
|
return (originalArray as ArrayWithFlatMap<T>).flatMap(fn);
|
|
35
34
|
}
|
package/src/utils/logger.ts
CHANGED
|
@@ -117,7 +117,6 @@ export default class Logger extends EventEmitter<ILoggerEvents> {
|
|
|
117
117
|
: (_namespace: string, consoleFn: IConsoleFn): IConsoleFn => consoleFn;
|
|
118
118
|
|
|
119
119
|
if (logFn === undefined) {
|
|
120
|
-
/* eslint-disable no-invalid-this */
|
|
121
120
|
/* eslint-disable no-console */
|
|
122
121
|
this.error =
|
|
123
122
|
level >= this._levels.ERROR
|
|
@@ -136,7 +135,6 @@ export default class Logger extends EventEmitter<ILoggerEvents> {
|
|
|
136
135
|
? generateLogFn("log", console.log.bind(console))
|
|
137
136
|
: noop;
|
|
138
137
|
/* eslint-enable no-console */
|
|
139
|
-
/* eslint-enable no-invalid-this */
|
|
140
138
|
} else {
|
|
141
139
|
const produceLogFn = (logLevel: ILoggerLevel) => {
|
|
142
140
|
return level >= this._levels[logLevel]
|
package/src/utils/noop.ts
CHANGED
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* is needed.
|
|
22
22
|
* Also, it allows to avoid telling eslint to ignore empty blocks everywhere.
|
|
23
23
|
*/
|
|
24
|
-
// eslint-disable-next-line
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
25
25
|
export default function (): void {}
|
|
@@ -73,7 +73,7 @@ function objectAssign<T extends object, U extends object[]>(
|
|
|
73
73
|
for (const source of sources) {
|
|
74
74
|
for (const key in source) {
|
|
75
75
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
77
77
|
to[key] = source[key as keyof typeof source];
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -81,9 +81,8 @@ function objectAssign<T extends object, U extends object[]>(
|
|
|
81
81
|
return to as MergeRecursively<T, U>;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// eslint-disable-next-line
|
|
84
|
+
// eslint-disable-next-line no-restricted-properties
|
|
85
85
|
export default typeof Object.assign === "function"
|
|
86
86
|
? // eslint-disable-next-line no-restricted-properties
|
|
87
87
|
Object.assign
|
|
88
|
-
:
|
|
89
|
-
objectAssign;
|
|
88
|
+
: objectAssign;
|
|
@@ -22,7 +22,7 @@ function objectValues<T>(o: { [s: string]: T }): T[] {
|
|
|
22
22
|
return Object.keys(o).map((k: string) => o[k]);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// eslint-disable-next-line
|
|
25
|
+
// eslint-disable-next-line no-restricted-properties
|
|
26
26
|
export default typeof Object.values === "function" ? Object.values : objectValues;
|
|
27
27
|
|
|
28
28
|
export { objectValues };
|
package/src/utils/request/xhr.ts
CHANGED
|
@@ -49,7 +49,7 @@ export default function request(
|
|
|
49
49
|
options: IRequestOptions<"document">,
|
|
50
50
|
): Promise<IRequestResponse<Document, "document">>;
|
|
51
51
|
export default function request(
|
|
52
|
-
options: IRequestOptions<"json">,
|
|
52
|
+
options: IRequestOptions<"json">,
|
|
53
53
|
): Promise<IRequestResponse<object, "json">>;
|
|
54
54
|
export default function request(
|
|
55
55
|
options: IRequestOptions<"blob">,
|
|
@@ -108,7 +108,7 @@ export default function request<T>(
|
|
|
108
108
|
if (!isNullOrUndefined(headers)) {
|
|
109
109
|
const _headers = headers;
|
|
110
110
|
for (const key in _headers) {
|
|
111
|
-
if (
|
|
111
|
+
if (Object.prototype.hasOwnProperty.call(_headers, key)) {
|
|
112
112
|
xhr.setRequestHeader(key, _headers[key]);
|
|
113
113
|
}
|
|
114
114
|
}
|
package/src/utils/starts_with.ts
CHANGED
|
@@ -29,7 +29,6 @@ export default function startsWith(
|
|
|
29
29
|
searchString: string,
|
|
30
30
|
position?: number,
|
|
31
31
|
): boolean {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
33
32
|
// eslint-disable-next-line no-restricted-properties
|
|
34
33
|
if (typeof String.prototype.startsWith === "function") {
|
|
35
34
|
// eslint-disable-next-line no-restricted-properties
|
|
@@ -299,7 +299,7 @@ function utf8ToStr(data: Uint8Array): string {
|
|
|
299
299
|
} else {
|
|
300
300
|
// Let's implement a simple escape function
|
|
301
301
|
// http://ecma-international.org/ecma-262/9.0/#sec-escape-string
|
|
302
|
-
const nonEscapedChar = /[A-Za-z0-9*_
|
|
302
|
+
const nonEscapedChar = /[A-Za-z0-9*_+-./]/;
|
|
303
303
|
escaped = "";
|
|
304
304
|
for (let i = 0; i < utf8Str.length; i++) {
|
|
305
305
|
if (nonEscapedChar.test(utf8Str[i])) {
|
package/src/utils/url-utils.ts
CHANGED
|
@@ -34,7 +34,7 @@ const schemeRe = /^(?:[a-z]+:)?\/\//i;
|
|
|
34
34
|
* 5th match is the fragment (e.g "nose")
|
|
35
35
|
* */
|
|
36
36
|
const urlComponentRegex =
|
|
37
|
-
/^(?:([
|
|
37
|
+
/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* In a given URL, find the index at which the filename begins.
|
|
@@ -154,7 +154,7 @@ function getRelativeUrl(baseUrl: string, newUrl: string): string | null {
|
|
|
154
154
|
* @param base
|
|
155
155
|
* @param relative
|
|
156
156
|
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
|
|
157
|
-
* @example base: http://example.com |
|
|
157
|
+
* @example base: http://example.com | relative: /b/c | output: http://example.com/b/c
|
|
158
158
|
* @returns the resolved url
|
|
159
159
|
*/
|
|
160
160
|
function _resolveURL(base: string, relative: string) {
|