Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
georgechoustoulakis committed Jul 19, 2024
1 parent 8878da5 commit 99bea78
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 212 deletions.
99 changes: 49 additions & 50 deletions adscript/src/adscript/AdScript.d.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,75 @@
export type JHMTApiProtocol = "https:" | "http:" | "file:"
export type JHMTApiProtocol = 'https:' | 'http:' | 'file:';
interface I12n {
i1: string;
i2: string;
i3: string;
i4: string;
i5: string;
i1: string;
i2: string;
i3: string;
i4: string;
i5: string;
}

export type MainVideoContentType = "content"
export type EmbeddedContentType = "preroll" | "midroll" | "postroll"
export type StaticContentType = "static"
export type MainVideoContentType = 'content';
export type EmbeddedContentType = 'preroll' | 'midroll' | 'postroll';
export type StaticContentType = 'static';

export interface MainVideoContentMetadata {
assetid: string;
type: MainVideoContentType;
program: string;
title: string;
length: string;
crossId: string;
livestream: string;
channelId: string;
attributes: string;
assetid: string;
type: MainVideoContentType;
program: string;
title: string;
length: string;
crossId: string;
livestream: string;
channelId: string;
attributes: string;
}

interface EmbeddedContentMetadata {
assetid: string;
type: EmbeddedContentType;
length: string;
title: string;
asmea: string;
attributes: string;
assetid: string;
type: EmbeddedContentType;
length: string;
title: string;
asmea: string;
attributes: string;
}


interface StaticContentMetadata {
assetid: string;
type: MainVideoContentType;
sec1: string;
sec2: string;
sec3: string;
sec4: string;
ref: string;
assetid: string;
type: MainVideoContentType;
sec1: string;
sec2: string;
sec3: string;
sec4: string;
ref: string;
}

export interface PlayerState {
muted: number;
volume: number;
triggeredByUser: number;
normalSpeed: number;
fullscreen: number;
visibility: number;
width: number;
height: number;
muted: number;
volume: number;
triggeredByUser: number;
normalSpeed: number;
fullscreen: number;
visibility: number;
width: number;
height: number;
}

interface JHMTArray extends Array<any> {
i12n: I12n;
contentMetadata: ContentMetadata;
playerState: PlayerState;
push: (item: any) => number; // Type of the push function
i12n: I12n;
contentMetadata: ContentMetadata;
playerState: PlayerState;
push: (item: any) => number; // Type of the push function
}

declare global {
interface Window {
JHMT: JHMTArray;
JHMTApi: typeof JHMTApi;
JHMTApiProtocol: JHMTApiProtocol
}
interface Window {
JHMT: JHMTArray;
JHMTApi: typeof JHMTApi;
JHMTApiProtocol: JHMTApiProtocol;
}
}

export interface JHMTApi {
setI12n(i12n: I12n);
setContentMetadata(contentMetadata: ContentMetadata);
setPlayerState(playerState: PlayerState);
}
}
2 changes: 1 addition & 1 deletion adscript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { AdScriptConnector } from './integration/AdScriptConnector';
export * from './integration/AdScriptConfiguration'
export * from './integration/AdScriptConfiguration';
10 changes: 5 additions & 5 deletions adscript/src/integration/AdScriptConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Ad } from "theoplayer";
import { EmbeddedContentMetadata } from "../adscript/AdScript";
import { Ad } from 'theoplayer';
import { EmbeddedContentMetadata } from '../adscript/AdScript';

export interface AdScriptConfiguration {
implementationId: string;
i12n: {[key: string]: string}
i12n: { [key: string]: string };
debug?: boolean;
adProcessor?: (ad: Ad) => EmbeddedContentMetadata
}
adProcessor?: (ad: Ad) => EmbeddedContentMetadata;
}
37 changes: 18 additions & 19 deletions adscript/src/integration/AdScriptConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { MainVideoContentMetadata } from '../adscript/AdScript';
import { Logger } from '../utils/Logger';

export class AdScriptConnector {

private adscriptIntegration: AdScriptTHEOIntegration | undefined;

/**
Expand All @@ -15,37 +14,37 @@ export class AdScriptConnector {
* @param metadata the MainVideoContentMetadata
* @returns
*/
constructor(player: ChromelessPlayer, configuration: AdScriptConfiguration, metadata: MainVideoContentMetadata) {
const interval = window.setInterval(() => {
if (typeof window.JHMTApi === 'object') {
window.clearInterval(interval);
const { i12n } = configuration
constructor(player: ChromelessPlayer, configuration: AdScriptConfiguration, metadata: MainVideoContentMetadata) {
const interval = window.setInterval(() => {
if (typeof window.JHMTApi === 'object') {
window.clearInterval(interval);
const { i12n } = configuration;
for (const id in i12n) {
window.JHMTApi.setI12n(id, i12n[id])
window.JHMTApi.setI12n(id, i12n[id]);
Logger.logsetI12n(id, i12n[id]);
}
this.adscriptIntegration = new AdScriptTHEOIntegration(player, configuration, metadata)

}
}, 20)
this.adscriptIntegration = new AdScriptTHEOIntegration(player, configuration, metadata);
}
}, 20);
window.setTimeout(() => {
if (!window.JHMTApi) {
window.clearInterval(interval)
console.error('JHMT API not found, make sure you included the script to initialize AdScript Measurement')
window.clearInterval(interval);
console.error(
'JHMT API not found, make sure you included the script to initialize AdScript Measurement'
);
return;
}
}, 5000)
}, 5000);
}

updateMetadata(metadata: any): void {
this.adscriptIntegration?.updateMetadata(metadata)
this.adscriptIntegration?.updateMetadata(metadata);
}


/**
* Destroy
* Destroy
*/
destroy(): void {
this.adscriptIntegration?.destroy()
this.adscriptIntegration?.destroy();
}
}
}
Loading

0 comments on commit 99bea78

Please sign in to comment.