Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to latest Conviva types #105

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
456 changes: 456 additions & 0 deletions @types/conviva/Conviva.d.ts

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions @types/conviva/ConvivaExtension.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* The following properties exist in the `window.Conviva` object but they are missing
* in types of `conviva-core-sdk` package for some reason, so let's add them manually.
*/

declare module Conviva {
class ContentMetadata {
public static readonly StreamType: Conviva.ConvivaConstants['StreamType']
public applicationName: string;
public assetName: string;
public custom: {};
public defaultResource: string;
public duration: number;
public encodedFrameRate: number;
public streamType: Conviva.valueof<Conviva.ConvivaConstants['StreamType']>;
public streamUrl: string;
public viewerId: string;
}

interface LoggingInterface {
consoleLog(message: string, logLevel: Conviva.valueof<Conviva.ConvivaConstants['LogLevel']>): void;

release(): void;
}

class SystemSettings {
public static readonly LogLevel: Conviva.ConvivaConstants['LogLevel'];
public allowUncaughtExceptions: boolean;
public httpTimeout: number;
public logLevel: Conviva.valueof<Conviva.ConvivaConstants['LogLevel']>;
public storageTimeout: number;
}

interface TimeInterface {
getEpochTimeMs(): number;

release(): void;
}

type TimerAction = () => void;

type TimerCancelFunction = () => void;

interface TimerInterface {
createTimer(timerAction: TimerAction, intervalMs: number, actionName?: string | null): TimerCancelFunction;

release(): void;
}

type HttpRequestCancelFunction = () => void;

type HttpRequestCallback = (succeeded: boolean, data: string) => void;

interface HttpInterface {
makeRequest(
httpMethod: 'GET' | 'POST',
url: string,
data: string | null,
contentType: string | null,
timeoutMs: number,
callback: HttpRequestCallback | null,
): HttpRequestCancelFunction;

release(): void;
}

type StorageLoadDataCallback = (succeeded: boolean, data: string | null) => void;

type StorageSaveDataCallback = (succeeded: boolean, data: string | null) => void;

interface StorageInterface {
loadData(storageSpace: string, storageKey: string, callback: StorageLoadDataCallback): void;

saveData(storageSpace: string, storageKey: string, data: string, callback: StorageSaveDataCallback): void;

release(): void;
}

interface VideoAnalytics {
reportAppEvent(eventType: string, eventDetail: { [key: string]: string }): void;
getSessionId(): number;
}
}
2 changes: 2 additions & 0 deletions @types/conviva/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './Conviva'
import './ConvivaExtension'
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- Updated Conviva types to the latest version and fixed some type issues

### Deprecated
- Removed `framework` and `frameworkVersion` custom metadata fields (custom tags)

## 4.2.0 - 2023-08-24
### Added
- Support for Conviva-SDK version 4.7.0
Expand Down
8 changes: 7 additions & 1 deletion example/conviva-core-sdk.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Definitions are copied from `conviva-core-sdk` package.
*/

export type valueof<T> = T[keyof T];

declare enum ConvivaKeys {
Expand Down Expand Up @@ -164,7 +168,9 @@ export interface ConvivaPlayerInfo {
}

export interface ConvivaPlayerExtraListeners {
[ConvivaKeys.MEDIA_ELEMENT]: object;
[Constants.MEDIA_ELEMENT]?: object;
[Constants.CONVIVA_MODULE]?: object;
[Constants.CONVIVA_AD_MODULE]?: object;
}

export interface ConvivaAdBreakInfo {
Expand Down
Loading
Loading