Skip to content

Commit

Permalink
chore: move mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzianis Dashkevich committed Oct 4, 2024
1 parent 3e7804f commit 6e9bea3
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/playback/src/lib/consts/interceptor-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
// since they can be used as values they should not be in the types folder
export enum InterceptorType {
NetworkRequest = 'NetworkRequest',
HlsPlaylistParse = 'HlsPlaylistParse',
}
2 changes: 1 addition & 1 deletion packages/playback/src/lib/network/network-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import { NetworkRequestWithChunkHandler, NetworkRequestWithMapper } from './network-request';
import type { PlayerNetworkConfiguration } from '../types/configuration.declarations';
import type { IEventEmitter } from '../types/event-emitter.declarations';
import type { NetworkEventMap } from '../types/event-type-to-event-map.declarations';
import type { NetworkEventMap } from '../types/mappers/event-type-to-event-map.declarations';

export interface NetworkManagerDependencies {
logger: ILogger;
Expand Down
2 changes: 1 addition & 1 deletion packages/playback/src/lib/network/network-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './network-manager-errors';
import type { ILogger } from '../types/logger.declarations';
import type { IEventEmitter } from '../types/event-emitter.declarations';
import type { NetworkEventMap } from '../types/event-type-to-event-map.declarations';
import type { NetworkEventMap } from '../types/mappers/event-type-to-event-map.declarations';
import {
NetworkRequestAttemptStartedEvent,
NetworkRequestAttemptFailedEvent,
Expand Down
2 changes: 1 addition & 1 deletion packages/playback/src/lib/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PlayerConfiguration } from './types/configuration.declarations';
import type { IStore } from './types/store.declarations';
import type { DeepPartial } from './types/utility.declarations';
import type { EventListener, IEventEmitter } from './types/event-emitter.declarations';
import type { EventTypeToEventMap } from './types/event-type-to-event-map.declarations';
import type { EventTypeToEventMap } from './types/mappers/event-type-to-event-map.declarations';
import { PlayerEventType } from './consts/events';
import {
ConfigurationChangedEvent,
Expand Down
4 changes: 2 additions & 2 deletions packages/playback/src/lib/service-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { IInterceptorsStorage } from './types/interceptors.declarations';
import type { PlayerConfiguration } from './types/configuration.declarations';
import type { IStore } from './types/store.declarations';
import type { IEventEmitter } from './types/event-emitter.declarations';
import type { EventTypeToEventMap } from './types/event-type-to-event-map.declarations';
import type { EventTypeToEventMap } from './types/mappers/event-type-to-event-map.declarations';
import type { IEnvCapabilitiesProvider } from './types/env-capabilities.declarations';
import type { INetworkManager } from './types/network.declarations';
import type { InterceptorTypeToInterceptorMap } from './types/interceptor-type-to-interceptor-map.declarations';
import type { InterceptorTypeToInterceptorMap } from './types/mappers/interceptor-type-to-interceptor-map.declarations';
import type { NetworkManagerDependencies } from './network/network-manager';

// Implementations
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InterceptorType } from '../consts/interceptor-type';
import type { InterceptorTypeToInterceptorMap } from './interceptor-type-to-interceptor-map.declarations';
import type { InterceptorTypeToInterceptorMap } from './mappers/interceptor-type-to-interceptor-map.declarations';

export interface IInterceptorsStorage {
addInterceptor<K extends InterceptorType>(interceptorType: K, interceptor: InterceptorTypeToInterceptorMap[K]): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mapping for types purposes
import type { PlayerEventType } from '../consts/events';
import type { PlayerEventType } from '../../consts/events';
import type {
ConfigurationChangedEvent,
LoggerLevelChangedEvent,
MutedStatusChangedEvent,
VolumeChangedEvent,
PlayerErrorEvent,
} from '../events/player-events';
} from '../../events/player-events';
import type {
NetworkRequestAttemptCompletedSuccessfullyEvent,
NetworkRequestAttemptCompletedUnsuccessfullyEvent,
NetworkRequestAttemptFailedEvent,
NetworkRequestAttemptStartedEvent,
} from '../events/network-events';
} from '../../events/network-events';

export interface NetworkEventMap {
[PlayerEventType.NetworkRequestAttemptStarted]: NetworkRequestAttemptStartedEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { InterceptorType } from '../../consts/interceptor-type';

export interface InterceptorTypeToInterceptorMap {
[InterceptorType.NetworkRequest]: (request: Request) => Promise<Request>;
[InterceptorType.HlsPlaylistParse]: (playlist: Uint8Array) => Promise<Uint8Array>;
}
2 changes: 1 addition & 1 deletion packages/playback/src/lib/types/network.declarations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RequestType } from '../consts/request-type';
import type { NetworkConfiguration, PlayerNetworkConfiguration } from './configuration.declarations';
import type { InterceptorTypeToInterceptorMap } from './interceptor-type-to-interceptor-map.declarations';
import type { InterceptorTypeToInterceptorMap } from './mappers/interceptor-type-to-interceptor-map.declarations';
import type { InterceptorType } from '../consts/interceptor-type';
import type { AttemptInfo } from './retry.declarations';

Expand Down
2 changes: 1 addition & 1 deletion packages/playback/src/lib/utils/interceptors-storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InterceptorType } from '../consts/interceptor-type';
import type { InterceptorTypeToInterceptorMap } from '../types/interceptor-type-to-interceptor-map.declarations';
import type { InterceptorTypeToInterceptorMap } from '../types/mappers/interceptor-type-to-interceptor-map.declarations';
import type { IInterceptorsStorage } from '../types/interceptors.declarations';

export class InterceptorsStorage implements IInterceptorsStorage {
Expand Down
2 changes: 1 addition & 1 deletion packages/playback/test/network/network-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
IRequestPayloadWithMapper,
} from '../../src/lib/types/network.declarations';
import type { IEventEmitter } from '../../src/lib/types/event-emitter.declarations';
import type { NetworkEventMap } from '../../src/lib/types/event-type-to-event-map.declarations';
import type { NetworkEventMap } from '../../src/lib/types/mappers/event-type-to-event-map.declarations';
import type { NetworkRequestDependencies } from '../../src/lib/network/network-request';
import type { NetworkConfiguration } from '../../src/lib/types/configuration.declarations';

Expand Down

0 comments on commit 6e9bea3

Please sign in to comment.