@@ -30,21 +30,23 @@ import ChromeAppDaemon from './chrome-app-daemon';
30
30
*/
31
31
export default function ChromeOsDaemon ( boardsUrl , options ) {
32
32
33
- // const { cacheStorageKey } = options;
34
- if ( false ) { // typeof options === 'string') {
35
- console . dir ( '******** BEGIN: chrome-os-daemon:40 ********' ) ;
36
- console . dir ( 'CREATING CHROME APP' , { depth : null , colors : true } ) ;
37
- console . dir ( '******** END: chrome-os-daemon:40 ********' ) ;
38
- // chrome app
39
- this . flavour = new ChromeAppDaemon ( boardsUrl , options ) ;
33
+ let useWebSerial = null ;
34
+ let chromeExtensionId ;
35
+
36
+ // check chromeExtensionId OR web serial API
37
+ if ( typeof options === 'string' ) {
38
+ chromeExtensionId = options ;
40
39
}
41
40
else {
42
- console . dir ( '******** BEGIN: chrome-os-daemon:47 ********' ) ;
43
- console . dir ( 'CREATING WEB SERIAL' , { depth : null , colors : true } ) ;
44
- console . dir ( '******** END: chrome-os-daemon:47 ********' ) ;
45
- // const { cacheStorageKey } = options;
41
+ useWebSerial = options . useWebSerial ;
42
+ chromeExtensionId = options . chromeExtensionId ;
43
+ }
44
+ if ( useWebSerial === 'true' && 'serial' in navigator ) {
46
45
this . flavour = new WebSerialDaemon ( boardsUrl ) ;
47
46
}
47
+ else {
48
+ this . flavour = new ChromeAppDaemon ( boardsUrl , chromeExtensionId ) ;
49
+ }
48
50
49
51
const handler = {
50
52
get : ( _ , name ) => this . flavour [ name ] ,
@@ -58,4 +60,3 @@ export default function ChromeOsDaemon(boardsUrl, options) {
58
60
return new Proxy ( this , handler ) ;
59
61
60
62
}
61
-
0 commit comments