diff --git a/lib/dependencies/all.js b/lib/dependencies/all.js index 6584e7d78a..faab54c306 100644 --- a/lib/dependencies/all.js +++ b/lib/dependencies/all.js @@ -14,7 +14,7 @@ shaka.dependencies = class { * Registers a new dependency. * * @param {shaka.dependencies.Allowed} key which is used for retrieving a - * dependency + * dependency * @param {?} dep a dependency * @export */ @@ -22,14 +22,15 @@ shaka.dependencies = class { if (!shaka.dependencies.Allowed[key]) { throw new Error(`${key} is not supported`); } - shaka.dependencies.dependencies_.set(key, dep); + shaka.dependencies.dependencies_.set(key, () => dep); } /** - * Check if we have a dependency for the key - * @export + * Check if we have a dependency for the key. + * * @param {shaka.dependencies.Allowed} key key * @return {boolean} + * @export */ static has(key) { return shaka.dependencies.dependencies_.has(key); @@ -38,16 +39,10 @@ shaka.dependencies = class { /** @return {?muxjs} */ static muxjs() { return /** @type {?muxjs} */ (shaka.dependencies.dependencies_.get( - shaka.dependencies.Allowed.muxjs)); + shaka.dependencies.Allowed.muxjs)()); } }; -/** - * Contains shared dependencies that could be used by other components. - * @private {!Map.} - */ -shaka.dependencies.dependencies_ = new Map(); - /** * @export * @enum {string} @@ -56,7 +51,12 @@ shaka.dependencies.Allowed = { muxjs: 'muxjs', }; -// Add global muxjs object for backward compatibility -shaka.dependencies.dependencies_.set( - shaka.dependencies.Allowed.muxjs, - window.muxjs); +/** + * Contains accessor functions to shared dependencies that could be used by + * other components. The default accessors can be overridden. + * + * @private {!Map.} + */ +shaka.dependencies.dependencies_ = new Map([ + [shaka.dependencies.Allowed.muxjs, () => window.muxjs], +]);