Permalink
Browse files

don't compile browserscripts with babel anymore

  • Loading branch information...
1 parent 6eee186 commit e0a0177551d347b08f7022bea2a45cb8c42984f3 @christian-bromann christian-bromann committed Aug 18, 2016
Showing with 88 additions and 71 deletions.
  1. +21 −7 gruntfile.js
  2. +3 −0 lib/browser/.eslintrc
  3. +8 −8 lib/browser/getStats.js
  4. +43 −43 lib/browser/startAnalyzing.js
  5. +13 −13 lib/browser/url.js
View
@@ -7,7 +7,7 @@ module.exports = function (grunt) {
files: [{
expand: true,
cwd: './lib',
- src: ['**/*.js'],
+ src: ['**/*.js', '!browser/*.js'],
dest: 'build',
ext: '.js'
}]
@@ -42,11 +42,24 @@ module.exports = function (grunt) {
},
watch: {
commands: {
- files: ['index.js', 'lib/**/*.js'],
- tasks: ['babel:commands'],
- options: {
- spawn: false
- }
+ files: ['lib/*.js', 'lib/helpers/*.js'],
+ tasks: ['babel'],
+ options: { spawn: false }
+ },
+ browserscripts: {
+ files: ['lib/browser/*.js'],
+ tasks: ['copy:browserscripts'],
+ options: { spawn: false }
+ }
+ },
+ copy: {
+ browserscripts: {
+ files: [{
+ expand: true,
+ cwd: 'lib',
+ src: 'browser/*.js',
+ dest: 'build'
+ }]
}
}
})
@@ -57,7 +70,8 @@ module.exports = function (grunt) {
grunt.task.run([
'eslint',
'clean',
- 'babel'
+ 'babel',
+ 'copy'
])
})
grunt.registerTask('release', 'Bump and tag version', function (type) {
@@ -1,5 +1,8 @@
{
"env": {
"browser": true
+ },
+ rules: {
+ semi: ["error", "always", { "omitLastInOneLineBlock": true}]
}
}
@@ -1,20 +1,20 @@
-export default function getStats (from, to, interval) {
- var recordedStats = Object.keys(window._webdriverrtc || {})
- var snapshots = []
+module.exports = function getStats (from, to, interval) {
+ var recordedStats = Object.keys(window._webdriverrtc || {});
+ var snapshots = [];
/**
* if no appropiate parameter was given return the last stat
*/
if (!from) {
- return window._webdriverrtc[recordedStats[recordedStats.length - 1]]
+ return window._webdriverrtc[recordedStats[recordedStats.length - 1]];
}
recordedStats.forEach(function (timestamp) {
- timestamp = parseInt(timestamp, 10)
+ timestamp = parseInt(timestamp, 10);
if (timestamp > (from - interval / 2) && (timestamp - interval / 2) < to) {
- snapshots.push(window._webdriverrtc[timestamp])
+ snapshots.push(window._webdriverrtc[timestamp]);
}
- })
+ });
- return snapshots
+ return snapshots;
};
@@ -1,44 +1,44 @@
/**
* this script gets executed in the browser
*/
-export default function startAnalyzing (_, pcSelectorMethod, interval) {
- var cb = arguments[arguments.length - 1]
+module.exports = function startAnalyzing (_, pcSelectorMethod, interval) {
+ var cb = arguments[arguments.length - 1];
/**
* merge objects (copied from deepmerge)
*/
function merge (target, src) {
- var dst = {}
+ var dst = {};
if (target && typeof target === 'object') {
Object.keys(target).forEach(function (key) {
- dst[key] = target[key]
- })
+ dst[key] = target[key];
+ });
}
Object.keys(src).forEach(function (key) {
if (typeof src[key] !== 'object' || !src[key]) {
- dst[key] = src[key]
+ dst[key] = src[key];
} else {
if (!target[key]) {
- dst[key] = src[key]
+ dst[key] = src[key];
} else {
- dst[key] = merge(target[key], src[key])
+ dst[key] = merge(target[key], src[key]);
}
}
- })
+ });
- return dst
+ return dst;
}
/**
* sanitize stat values
*/
function sanitize (val) {
if (typeof val !== 'string' && typeof val !== 'number') {
- return undefined
+ return undefined;
}
- return parseInt(val, 10)
+ return parseInt(val, 10);
}
/**
@@ -49,10 +49,10 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
audio: {},
video: {},
results: results
- }
+ };
for (var i = 0; i < results.length; ++i) {
- var res = results[i]
+ var res = results[i];
/**
* RTCOutboundRTPStreamStats
@@ -65,7 +65,7 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
inputLevel: sanitize(res.audioInputLevel),
packetsLost: sanitize(res.packetsLost),
jitter: sanitize(res.googJitterReceived)
- }
+ };
/**
* RTCInboundRTPStreamStats
@@ -77,7 +77,7 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
outputLevel: sanitize(res.audioOutputLevel),
packetsLost: sanitize(res.packetsLost),
jitter: sanitize(res.googJitterReceived)
- }
+ };
}
if (res.googCodecName === 'VP8') {
@@ -96,7 +96,7 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
captureJitterMs: sanitize(res.googCaptureJitterMs),
captureQueueDelayMsPerS: sanitize(res.googCaptureQueueDelayMsPerS),
encodeUsagePercent: sanitize(res.googEncodeUsagePercent)
- })
+ });
}
if (res.type === 'VideoBwe') {
@@ -108,30 +108,30 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
targetEncBitrate: sanitize(res.googTargetEncBitrate),
bucketDelay: sanitize(res.googBucketDelay),
transmitBitrate: sanitize(res.googTransmitBitrate)
- }
+ };
}
}
- var timestamp = new Date().getTime()
- window._webdriverrtc[timestamp] = result
+ var timestamp = new Date().getTime();
+ window._webdriverrtc[timestamp] = result;
}
/**
* get RTCStatsReports
*/
function getStats () {
pc.getStats(function (res) {
- var items = []
- var connectionType = {}
+ var items = [];
+ var connectionType = {};
res.result().forEach(function (result) {
- var item = {}
+ var item = {};
result.names().forEach(function (name) {
- item[name] = result.stat(name)
- })
- item.id = result.id
- item.type = result.type
- item.timestamp = result.timestamp
+ item[name] = result.stat(name);
+ });
+ item.id = result.id;
+ item.type = result.type;
+ item.timestamp = result.timestamp;
if (item.type === 'googCandidatePair' && item.googActiveConnection === 'true') {
connectionType = {
@@ -144,31 +144,31 @@ export default function startAnalyzing (_, pcSelectorMethod, interval) {
ipAddress: item.googRemoteAddress
},
transport: item.googTransportType
- }
+ };
- return
+ return;
}
- items.push(item)
- })
+ items.push(item);
+ });
- traceStats(items)
- window._webdriverrtcTimeout = setTimeout(getStats.bind(window, items), interval)
+ traceStats(items);
+ window._webdriverrtcTimeout = setTimeout(getStats.bind(window, items), interval);
if (typeof cb === 'function') {
- cb(connectionType)
- cb = undefined
+ cb(connectionType);
+ cb = undefined;
}
- })
+ });
}
- var pc = pcSelectorMethod() || window.webdriverRTCPeerConnectionBucket
+ var pc = pcSelectorMethod() || window.webdriverRTCPeerConnectionBucket;
if (!pc || pc.constructor.name !== 'RTCPeerConnection') {
- throw new Error('RTCPeerConnection not found')
+ throw new Error('RTCPeerConnection not found');
}
- window._webdriverrtc = {}
- window._webdriverrtcTimeout = null
- getStats()
-}
+ window._webdriverrtc = {};
+ window._webdriverrtcTimeout = null;
+ getStats();
+};
View
@@ -1,23 +1,23 @@
-export default function url () {
- var OriginalRTCPeerConnection
+module.exports = function url () {
+ var OriginalRTCPeerConnection;
/**
* method to masquerade RTCPeerConnection
*/
var masqueradeFunction = function (param1, param2, param3) {
- var pc = new OriginalRTCPeerConnection(param1, param2, param3)
- window.webdriverRTCPeerConnectionBucket = pc
- return pc
- }
+ var pc = new OriginalRTCPeerConnection(param1, param2, param3);
+ window.webdriverRTCPeerConnectionBucket = pc;
+ return pc;
+ };
if (window.RTCPeerConnection) {
- OriginalRTCPeerConnection = window.RTCPeerConnection
- window.RTCPeerConnection = masqueradeFunction
+ OriginalRTCPeerConnection = window.RTCPeerConnection;
+ window.RTCPeerConnection = masqueradeFunction;
} else if (window.webkitRTCPeerConnection) {
- OriginalRTCPeerConnection = window.webkitRTCPeerConnection
- window.webkitRTCPeerConnection = masqueradeFunction
+ OriginalRTCPeerConnection = window.webkitRTCPeerConnection;
+ window.webkitRTCPeerConnection = masqueradeFunction;
} else if (window.mozRTCPeerConnection) {
- OriginalRTCPeerConnection = window.mozRTCPeerConnection
- window.mozRTCPeerConnection = masqueradeFunction
+ OriginalRTCPeerConnection = window.mozRTCPeerConnection;
+ window.mozRTCPeerConnection = masqueradeFunction;
}
-}
+};

0 comments on commit e0a0177

Please sign in to comment.