1- 'use strict' ;
1+ import semver from "semver" ;
22
3- function microtime ( ) {
3+ export function microtime ( ) {
44 return new Date ( ) . getTime ( ) / 1000 ;
55}
66
7- function millitime ( ) {
7+ export function millitime ( ) {
88 return new Date ( ) . getTime ( ) ;
99}
1010
1111const DEGREE_TO_RADIAN_RATIO = Math . PI / 180 ;
1212
13- function degToRad ( degrees ) {
13+ export function degToRad ( degrees ) {
1414 return degrees * DEGREE_TO_RADIAN_RATIO ;
1515}
1616
17- function bytesToSize ( bytes ) {
18-
17+ export function bytesToSize ( bytes ) {
1918 let outputBytes ;
2019
2120 if ( bytes < 1024 ) {
@@ -35,27 +34,33 @@ function bytesToSize(bytes) {
3534 * checkChromeRuntimeError() has to be called after each chrome API call
3635 */
3736
38- function checkChromeRuntimeError ( ) {
37+ export function checkChromeRuntimeError ( ) {
3938 if ( chrome . runtime . lastError ) {
40- console . error ( `Chrome API Error: ${ chrome . runtime . lastError . message } .\n Traced ${ ( new Error ) . stack } ` ) ;
39+ console . error (
40+ `Chrome API Error: ${ chrome . runtime . lastError . message } .\n Traced ${
41+ new Error ( ) . stack
42+ } `
43+ ) ;
4144 return true ;
4245 }
4346 return false ;
4447}
4548
4649const majorFirmwareVersions = {
47- ' 1.43' : ' 4.2.*' ,
48- ' 1.42' : ' 4.1.*' ,
49- ' 1.41' : ' 4.0.*' ,
50- ' 1.40' : ' 3.5.*' ,
51- ' 1.39' : ' 3.4.*' ,
52- ' 1.37' : ' 3.3.0' ,
53- ' 1.36' : ' 3.2.*' ,
54- ' 1.31' : ' 3.1.0' ,
50+ " 1.43" : " 4.2.*" ,
51+ " 1.42" : " 4.1.*" ,
52+ " 1.41" : " 4.0.*" ,
53+ " 1.40" : " 3.5.*" ,
54+ " 1.39" : " 3.4.*" ,
55+ " 1.37" : " 3.3.0" ,
56+ " 1.36" : " 3.2.*" ,
57+ " 1.31" : " 3.1.0"
5558} ;
5659
57- function generateVirtualApiVersions ( ) {
58- const firmwareVersionDropdown = document . getElementById ( 'firmware-version-dropdown' ) ;
60+ export function generateVirtualApiVersions ( ) {
61+ const firmwareVersionDropdown = document . getElementById (
62+ "firmware-version-dropdown"
63+ ) ;
5964 const max = semver . minor ( CONFIGURATOR . API_VERSION_MAX_SUPPORTED ) ;
6065
6166 for ( let i = max ; i > 0 ; i -- ) {
@@ -73,3 +78,10 @@ function generateVirtualApiVersions() {
7378 firmwareVersionDropdown . appendChild ( option ) ;
7479 }
7580}
81+
82+ // TODO: these are temp binding while transition to module happens
83+ window . microtime = microtime ;
84+ window . degToRad = degToRad ;
85+ window . bytesToSize = bytesToSize ;
86+ window . checkChromeRuntimeError = checkChromeRuntimeError ;
87+ window . generateVirtualApiVersions = generateVirtualApiVersions ;
0 commit comments