-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
72 lines (61 loc) · 2.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var Promise = require('es6-promise').Promise
var Client = require('./lib/client')
var Server = require('./lib/server')
var logger = require('./lib/logger')
var DOMNodeCache = require('./lib/domNodeCache')
// Agents
var Animation = require('./agents/animation')
var Emulation = require('./agents/emulation')
var Info = require('./agents/info')
var Inspector = require('./agents/inspector')
var Console = require('./agents/console')
var Runtime = require('./agents/runtime')
var Page = require('./agents/page')
var CSS = require('./agents/css')
var DOM = require('./agents/dom')
var Network = require('./agents/network')
var Worker = require('./agents/worker')
// Options
var defaultOptions = {
client: {
port: 6000
},
server: {
port: 9223
}
}
function Adaptor (options) {
logger.info('adaptor.initialize')
this.options = options || defaultOptions
this.server = new Server(this.options)
this.client = new Client(this.options)
var domNodeCache = new DOMNodeCache()
this.agents = [
new Animation(this.server, this.client, domNodeCache),
new Console(this.server, this.client, domNodeCache),
new CSS(this.server, this.client, domNodeCache),
new DOM(this.server, this.client, domNodeCache),
new Emulation(this.server, this.client, domNodeCache),
new Page(this.server, this.client, domNodeCache),
new Info(this.server, this.client, domNodeCache),
new Inspector(this.server, this.client, domNodeCache),
new Network(this.server, this.client, domNodeCache),
new Runtime(this.server, this.client, domNodeCache),
new Worker(this.server, this.client, domNodeCache)
]
}
Adaptor.prototype = {
start: function () {
logger.info('adaptor.start')
var whenReady = Promise.all([this.server.start(), this.client.connect()])
whenReady
.then(function () {
logger.info('adaptor.ready')
logger.info('-> visit http://localhost:' + this.options.server.port + '/json/')
}.bind(this))
.catch(function (err) {
logger.error('adaptor.error', err)
})
}
}
module.exports = Adaptor