Skip to content

Commit

Permalink
Split core player from embed script (#2156)
Browse files Browse the repository at this point in the history
Split the controller and all it's dependencies from the api and it's dependencies.
Remove babelrc

JW8-106
  • Loading branch information
robwalch authored and johnBartos committed Jul 18, 2017
1 parent 5bbbc8f commit 99914e1
Show file tree
Hide file tree
Showing 45 changed files with 1,281 additions and 1,104 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

12 changes: 6 additions & 6 deletions karma.conf.js
Expand Up @@ -31,17 +31,17 @@ webpackConfig.module.rules = rules.concat(webpackConfig.module.rules || []);
webpackConfig.module.noParse = noParse.concat(webpackConfig.module.noParse || []);

module.exports = function(config) {
var env = process.env;
var isJenkins = !!process.env.JENKINS_HOME;
var serverPort = process.env.KARMA_PORT || 9876;
var testReporters = [
const env = process.env;
const isJenkins = !!env.JENKINS_HOME;
const serverPort = env.KARMA_PORT || 9876;
const testReporters = [
'mocha',
'coverage-istanbul'
];
if (isJenkins) {
testReporters.push('junit');
}
var packageInfo = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));
const packageInfo = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));

config.set({
frameworks: ['mocha', 'chai', 'sinon'],
Expand Down Expand Up @@ -115,7 +115,7 @@ module.exports = function(config) {
__SELF_HOSTED__: true,
__REPO__: '\'\'',
__DEBUG__: false,
__BUILD_VERSION__: '\'' + '7.10.0' + '\'',
__BUILD_VERSION__: '\'' + '7.12.0' + '\'',
__FLASH_VERSION__: 18.0
}),
],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -13,6 +13,7 @@
"babel-core": "6.24.0",
"babel-loader": "6.4.1",
"babel-plugin-transform-es2015-modules-commonjs": "6.24.0",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-es2015": "6.24.0",
"chai": "3.5.0",
"css-loader": "0.26.4",
Expand All @@ -34,7 +35,7 @@
"intersection-observer": "0.3.2",
"istanbul-instrumenter-loader": "1.2.0",
"jquery": "3.2.1",
"jsdoc": "^3.4.3",
"jsdoc": "3.4.3",
"karma": "1.5.0",
"karma-browserstack-launcher": "1.2.0",
"karma-chai": "0.1.0",
Expand Down
50 changes: 50 additions & 0 deletions src/js/api/api-queue.js
@@ -0,0 +1,50 @@

export default function ApiQueueDecorator(instance, queuedCommands, predicate) {
const commandQueue = [];
const undecoratedMethods = {};

queuedCommands.forEach((command) => {
const method = instance[command];
undecoratedMethods[command] = method;

instance[command] = function() {
const args = Array.prototype.slice.call(arguments, 0);

if (predicate()) {
commandQueue.push({ command, args });
} else {
executeQueuedCommands();
if (method) {
method.apply(this, args);
}
}
};
});

function executeQueuedCommands() {
while (commandQueue.length > 0) {
const { command, args } = commandQueue.shift();
(undecoratedMethods[command] || instance[command]).apply(instance, args);
}
}

Object.defineProperty(this, 'queue', {
enumerable: true,
get: function() {
return commandQueue;
}
});

this.flush = executeQueuedCommands;

this.destroy = function() {
commandQueue.forEach(({ command }) => {
const method = undecoratedMethods[command];
if (method) {
instance[command] = method;
delete undecoratedMethods[command];
}
});
commandQueue.length = 0;
};
}

0 comments on commit 99914e1

Please sign in to comment.