提交 4733439c 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

#40 typescript compile success!

上级 f5d4afd7
...@@ -52,3 +52,4 @@ t/ ...@@ -52,3 +52,4 @@ t/
t.* t.*
.DS_Store .DS_Store
/dev.js /dev.js
/dist/
...@@ -80,7 +80,7 @@ class IoClient { ...@@ -80,7 +80,7 @@ class IoClient {
this.targetState('connected') this.targetState('connected')
this.currentState('connecting') this.currentState('connecting')
this.wechaty = new Wechaty({ this.wechaty = Wechaty.instance({
profile: Config.DEFAULT_PROFILE profile: Config.DEFAULT_PROFILE
}) })
...@@ -165,7 +165,7 @@ class IoClient { ...@@ -165,7 +165,7 @@ class IoClient {
res.send('Wechaty IO Bot Alive!') res.send('Wechaty IO Bot Alive!')
}) })
return new Promise((resolve, reject) => { return new Promise((resolve) => {
app.listen(port, () => { app.listen(port, () => {
this.log.verbose('IoClient', 'initWeb() Wechaty IO Bot listening on port ' + port + '!') this.log.verbose('IoClient', 'initWeb() Wechaty IO Bot listening on port ' + port + '!')
......
...@@ -17,9 +17,9 @@ import Message from './message' ...@@ -17,9 +17,9 @@ import Message from './message'
import Room from './room' import Room from './room'
import log from './brolog-env' import log from './brolog-env'
type ContactGetterFunc = { // type ContactGetterFunc = {
(id: string): Promise<any> // (id: string): Promise<any>
} // }
abstract class Puppet extends EventEmitter { abstract class Puppet extends EventEmitter {
public user: Contact public user: Contact
......
...@@ -44,6 +44,16 @@ class Wechaty extends EventEmitter { ...@@ -44,6 +44,16 @@ class Wechaty extends EventEmitter {
public uuid: string public uuid: string
public static instance(setting?: WechatySetting) {
if (setting && this._instance) {
throw new Error('there has already a instance. no params allowed any more')
}
if (!this._instance) {
this._instance = new Wechaty(setting)
}
return this._instance
}
private constructor(private setting: WechatySetting) { private constructor(private setting: WechatySetting) {
super() super()
log.verbose('Wechaty', 'contructor()') log.verbose('Wechaty', 'contructor()')
...@@ -72,13 +82,6 @@ class Wechaty extends EventEmitter { ...@@ -72,13 +82,6 @@ class Wechaty extends EventEmitter {
// Wechaty._instance = this // Wechaty._instance = this
} }
public static instance(setting: WechatySetting) {
if (!this._instance) {
this._instance = new Wechaty(setting)
}
return this._instance
}
public toString() { return 'Class Wechaty(' + this.setting.type + ')'} public toString() { return 'Class Wechaty(' + this.setting.type + ')'}
public version(forceNpm = false) { public version(forceNpm = false) {
......
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6" "target": "es6"
, "module": "amd"
, "moduleResolution": "node" , "moduleResolution": "node"
, "outDir": "dist" , "outDir": "dist"
, "noImplicitAny": false , "outFile": "dist/wechaty.lib.js"
, "strictNullChecks": true
, "sourceMap": true , "sourceMap": true
, "noUnusedLocals": true
, "noUnusedParameters": false
, "strictNullChecks": false
, "noImplicitAny": false
, "noImplicitThis": false
, "noImplicitReturns": false
, "noFallthroughCasesInSwitch": false
} }
, "exclude": [ , "exclude": [
"node_modules" "node_modules"
, "dist" , "dist"
, "**/*.spec.ts"
] ]
, "files": [ , "include": [
"src/*.ts" "src/**/*.ts"
, "bin/*.ts" // , "bin/*.ts"
, "example/*.ts" // , "example/*.ts"
// , "test/*.ts" // , "test/*.ts"
] ]
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册