Skip to content

Commit

Permalink
Refactor engine types
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko committed May 29, 2024
1 parent d78144e commit e7cda7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
20 changes: 8 additions & 12 deletions packages/p2p-media-loader-hlsjs/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ import {
} from "p2p-media-loader-core";
import { injectMixin } from "./engine-static";

/**
* Represents the complete configuration for HlsJsP2PEngine.
*/
/** Represents the complete configuration for HlsJsP2PEngine. */
export type HlsJsP2PEngineConfig = {
/** Core configuration */
core: CoreConfig;
};

/**
* Allows for partial configuration of HlsJsP2PEngine, useful for providing overrides or partial updates.
*/
/** Allows for partial configuration of HlsJsP2PEngine, useful for providing overrides or partial updates. */
export type PartialHlsJsP2PEngineConfig = Partial<
Omit<HlsJsP2PEngineConfig, "core">
> & {
/** Partial core configuration */
core?: Partial<CoreConfig>;
};

/**
* Type for specifying dynamic configuration options that can be changed at runtime for the P2P engine's core.
*/
/** Type for specifying dynamic configuration options that can be changed at runtime for the P2P engine's core. */
export type DynamicHlsJsP2PEngineConfig = {
/** Dynamic core configuration */
core?: DynamicCoreConfig;
};

Expand All @@ -47,6 +44,7 @@ export type DynamicHlsJsP2PEngineConfig = {
* @template HlsType The base HLS type that is being extended.
*/
export type HlsWithP2PInstance<HlsType> = HlsType & {
/** HlsJsP2PEngine instance */
readonly p2pEngine: HlsJsP2PEngine;
};

Expand Down Expand Up @@ -339,9 +337,7 @@ export class HlsJsP2PEngine {

private destroyCore = () => this.core.destroy();

/**
* Clean up and release all resources. Unregisters all event handlers.
*/
/** Clean up and release all resources. Unregisters all event handlers. */
destroy = () => {
this.destroyCore();
this.updateHlsEventsHandlers("unregister");
Expand Down
21 changes: 8 additions & 13 deletions packages/p2p-media-loader-shaka/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ import {
DynamicCoreConfig,
} from "p2p-media-loader-core";

/**
* Type for specifying dynamic configuration options that can be changed at runtime for the P2P engine's core.
*/
/** Type for specifying dynamic configuration options that can be changed at runtime for the P2P engine's core. */
export type DynamicShakaP2PEngineConfig = {
/** Dynamic core configuration */
core?: DynamicCoreConfig;
};

/**
* Represents the complete configuration for ShakaP2PEngine.
*/
/** Represents the complete configuration for ShakaP2PEngine. */
export type ShakaP2PEngineConfig = {
/** Core configuration */
core: CoreConfig;
};

/**
* Allows for partial configuration settings for the Shaka P2P Engine.
*/
/** Allows for partial configuration settings for the Shaka P2P Engine. */
export type PartialShakaEngineConfig = Partial<
Omit<ShakaP2PEngineConfig, "core">
> & {
/** Partial core configuration */
core?: Partial<CoreConfig>;
};

Expand Down Expand Up @@ -272,9 +269,7 @@ export class ShakaP2PEngine {
this.core.updatePlayback(media.currentTime, media.playbackRate);
};

/**
* Clean up and release all resources. Unregisters all event handlers.
*/
/** Clean up and release all resources. Unregister all event handlers. */
destroy() {
this.destroyCurrentStreamContext();
this.updatePlayerEventHandlers("unregister");
Expand Down Expand Up @@ -343,7 +338,7 @@ export class ShakaP2PEngine {
}

/**
* Unregisters plugins related to P2P functionality from the Shaka Player.
* Unregister plugins related to P2P functionality from the Shaka Player.
*
* @param {Shaka} [shaka=window.shaka] - The Shaka Player library. Defaults to the global Shaka Player instance if not provided.
*/
Expand Down

0 comments on commit e7cda7c

Please sign in to comment.