Skip to content

Commit e3676e7

Browse files
author
Stefania
committedNov 23, 2018
autodetect env
1 parent ab06443 commit e3676e7

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed
 

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install arduino-create-agent-js-client --save
1515
```js
1616
import Daemon from 'arduino-create-agent-js-client';
1717

18-
const daemon = new Daemon('https://builder.arduino.cc/v3/boards');
18+
const daemon = new Daemon();
1919

2020
daemon.agentFound.subscribe(status => {
2121
// true / false

‎demo/app.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const scrollToBottom = (target) => {
3131
}
3232
};
3333

34-
const daemon = new Daemon('https://builder.arduino.cc/v3/boards', chromeExtensionID);
34+
const daemon = new Daemon(chromeExtensionID);
3535

3636
const handleUpload = () => {
3737
const target = {

‎src/chrome-app-daemon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import Daemon from './daemon';
2626
const POLLING_INTERVAL = 2000;
2727

2828
export default class ChromeOsDaemon extends Daemon {
29-
constructor(boardsUrl, chromeExtensionId) {
30-
super(boardsUrl);
29+
constructor(chromeExtensionId) {
30+
super();
3131
this.channel = null;
3232

3333
this.openChannel(() => this.channel.postMessage({

‎src/daemon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import { takeUntil, filter, startWith, first, distinctUntilChanged } from 'rxjs/
2424
const POLLING_INTERVAL = 1500;
2525

2626
export default class Daemon {
27-
constructor(boardsUrl = 'https://builder.arduino.cc/v3/boards') {
28-
this.BOARDS_URL = boardsUrl;
27+
constructor() {
2928
this.UPLOAD_NOPE = 'UPLOAD_NOPE';
3029
this.UPLOAD_DONE = 'UPLOAD_DONE';
3130
this.UPLOAD_ERROR = 'UPLOAD_ERROR';
@@ -112,8 +111,9 @@ export default class Daemon {
112111

113112
this.closeSerialMonitor(target.port);
114113

114+
const IS_DEV = window.location.hostname.indexOf('-dev') !== -1 || window.location.hostname.indexOf('local') !== -1 ? '-dev' : '';
115115
// Fetch command line for the board
116-
fetch(`${this.BOARDS_URL}/${target.board}/compute`, {
116+
fetch(`https://builder${IS_DEV}.arduino.cc/v3/boards/${target.board}/compute`, {
117117
method: 'POST',
118118
body: JSON.stringify({ action: 'upload', verbose })
119119
})

‎src/socket-daemon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ if (browser.name !== 'chrome' && browser.name !== 'firefox') {
5454
}
5555

5656
export default class SocketDaemon extends Daemon {
57-
constructor(boardsUrl) {
58-
super(boardsUrl);
57+
constructor() {
58+
super();
5959
this.selectedProtocol = PROTOCOL.HTTP;
6060
this.socket = null;
6161
this.pluginURL = null;

0 commit comments

Comments
 (0)
Please sign in to comment.