Skip to content

Commit

Permalink
fix(FEC-7123): include global webpack var in flow config (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv authored and yairans committed Sep 27, 2017
1 parent 32c41fc commit d77e96a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.*/node_modules/playkit-js-providers/src/
[include]
[libs]
./src/index.js
node_modules/playkit-js/flow-typed/
node_modules/playkit-js-hls/flow-typed/
node_modules/playkit-js-dash/flow-typed/
Expand Down
3 changes: 1 addition & 2 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import LoggerFactory from './utils/logger'
import {addKalturaParams} from './utils/kaltura-params'
import {addKalturaPoster} from './utils/setup-helpers'
import {evaluatePluginsConfig} from './plugins/plugins-config'
import {VERSION} from "./index";
import './assets/style.css'

export default class KalturaPlayer {
Expand All @@ -19,7 +18,7 @@ export default class KalturaPlayer {
this._player = player;
this._logger = LoggerFactory.getLogger('KalturaPlayer' + Utils.Generator.uniqueId(5));
this._uiManager = new PlaykitUI(this._player, {targetId: targetId});
this._provider = new OvpProvider(VERSION, config.partnerId, config.ks, config.env);
this._provider = new OvpProvider(__VERSION__, config.partnerId, config.ks, config.env);
this._uiManager.buildDefaultUI();
return {
loadMedia: this.loadMedia.bind(this)
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/plugins-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pluginsConfig from './plugins-config.json'
import evaluate from '../utils/evaluate'
import {Utils} from 'playkit-js'
import {PLAYER_NAME, VERSION} from "../index";


/**
* @param {Object} [playerConfig = {}] - The player config
Expand All @@ -13,8 +11,8 @@ import {PLAYER_NAME, VERSION} from "../index";
function evaluatePluginsConfig(playerConfig: Object = {}): void {
if (playerConfig.plugins) {
let dataModel = {
pVersion: VERSION,
pName: PLAYER_NAME,
pVersion: __VERSION__,
pName: __NAME__
};
if (playerConfig.session) {
let entryDataModel = {
Expand Down
3 changes: 1 addition & 2 deletions src/storage/storage-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// @flow
import LoggerFactory from '../utils/logger'
import {PLAYER_NAME} from "../index";

const STORAGE_PREFIX = PLAYER_NAME + '_';
const STORAGE_PREFIX = __NAME__ + '_';

export default class StorageWrapper {
static _logger: any = LoggerFactory.getLogger('StorageWrapper');
Expand Down
4 changes: 2 additions & 2 deletions src/utils/kaltura-params.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@flow
import {Utils, VERSION} from 'playkit-js'
import {Utils} from 'playkit-js'

const PLAY_MANIFEST = 'playmanifest/';
const PLAY_SESSION_ID = 'playSessionId=';
Expand Down Expand Up @@ -80,7 +80,7 @@ function addReferrer(source: Object) {
function addClientTag(source: Object) {
if (source.url.indexOf(CLIENT_TAG) === -1) {
let delimiter = source.url.indexOf('?') === -1 ? '?' : '&';
source.url += delimiter + CLIENT_TAG + VERSION;
source.url += delimiter + CLIENT_TAG + __VERSION__;
}
}

Expand Down
13 changes: 6 additions & 7 deletions test/src/utils/kaltura-params.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
addReferrer,
addClientTag
} from '../../../src/utils/kaltura-params'
import {VERSION} from 'playkit-js'

class Player {
set sessionId(s) {
Expand All @@ -22,17 +21,17 @@ describe('addKalturaParams', function () {
let source2 = {url: 'd/e/f/playmanifest/source?a'};
player.config = {session: {}, sources: {progressive: [source1, source2]}};
addKalturaParams(player.config.sources, player);
source1.url.should.be.equal('a/b/c/playmanifest/source?playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + VERSION);
source2.url.should.be.equal('d/e/f/playmanifest/source?a&playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + VERSION);
source1.url.should.be.equal('a/b/c/playmanifest/source?playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + __VERSION__);
source2.url.should.be.equal('d/e/f/playmanifest/source?a&playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + __VERSION__);
});

it('should add session id, referrer and client tag for PLAYMANIFEST source', function () {
let source1 = {url: 'a/b/c/PLAYMANIFEST/source'};
let source2 = {url: 'd/e/f/PLAYMANIFEST/source?a'};
player.config = {session: {}, sources: {progressive: [source1, source2]}};
addKalturaParams(player.config.sources, player);
source1.url.should.be.equal('a/b/c/PLAYMANIFEST/source?playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + VERSION);
source2.url.should.be.equal('d/e/f/PLAYMANIFEST/source?a&playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + VERSION);
source1.url.should.be.equal('a/b/c/PLAYMANIFEST/source?playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + __VERSION__);
source2.url.should.be.equal('d/e/f/PLAYMANIFEST/source?a&playSessionId=' + player.config.session.id + '&referrer=' + btoa(document.referrer) + '&clientTag=html5:v' + __VERSION__);
});

it('should add nothing for no playManifest source', function () {
Expand Down Expand Up @@ -115,13 +114,13 @@ describe('addClientTag', function () {
let source = {url: 'a/b/c/playmanifest/source'};
player.config = {session: {}};
addClientTag(source, player);
source.url.should.be.equal('a/b/c/playmanifest/source?clientTag=html5:v' + VERSION);
source.url.should.be.equal('a/b/c/playmanifest/source?clientTag=html5:v' + __VERSION__);
});

it('should add client tag as second param', function () {
let source = {url: 'a/b/c/playmanifest/source?a'};
player.config = {session: {}};
addClientTag(source, player);
source.url.should.be.equal('a/b/c/playmanifest/source?a&clientTag=html5:v' + VERSION);
source.url.should.be.equal('a/b/c/playmanifest/source?a&clientTag=html5:v' + __VERSION__);
});
});

0 comments on commit d77e96a

Please sign in to comment.