Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
bdcb37e7
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bdcb37e7
编写于
10月 26, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix win32 sloc bug, code clean
上级
dd228d20
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
30 addition
and
20 deletion
+30
-20
package.json
package.json
+1
-1
src/io-client.ts
src/io-client.ts
+2
-2
src/io.ts
src/io.ts
+2
-2
src/puppet-web/browser.ts
src/puppet-web/browser.ts
+2
-2
src/puppet.ts
src/puppet.ts
+2
-2
src/state-monitor.spec.ts
src/state-monitor.spec.ts
+5
-2
src/state-monitor.ts
src/state-monitor.ts
+16
-9
未找到文件。
package.json
浏览文件 @
bdcb37e7
...
...
@@ -23,7 +23,7 @@
"eslint"
:
"eslint
\"
{bin,example,src,test}/**/*.js
\"
"
,
"tslint"
:
"tslint
\"
{bin,example,src,test}/**/*.ts
\"
&& tsc --noEmit"
,
"pretest"
:
"npm run lint && npm run clean && npm run build"
,
"sloc"
:
"sloc . --details --format cli-table --keys total,source,comment --exclude
\"\\
.
\\
.
/|dist/|doc/|node_modules/
\"
&& sloc ./ --exclude
\"\\
.
\\
./|dist/|doc/|node_modules/
\"
"
,
"sloc"
:
"sloc . --details --format cli-table --keys total,source,comment --exclude
\"\\
.
\\
.
[
\\
/]|dist[
\\
/]|doc[
\\
/]|node_modules[
\\
/]
\"
&& sloc ./ --exclude
\"\\
.
\\
.[
\\
/]|dist[
\\
/]|doc[
\\
/]|node_modules[
\\
/]
\"
"
,
"test"
:
"npm run test:chrome"
,
"posttest"
:
"npm run clean && npm run sloc"
,
"test:phantomjs"
:
"cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m
\"
dist/test/*.spec.js
\"
"
,
...
...
src/io-client.ts
浏览文件 @
bdcb37e7
...
...
@@ -49,8 +49,8 @@ export class IoClient {
// this.targetState('disconnected')
// this.currentState('disconnected')
this
.
state
.
target
(
'
offline
'
)
this
.
state
.
current
(
'
offline
'
)
//
this.state.target('offline')
//
this.state.current('offline')
}
// // targetState : 'connected' | 'disconnected'
...
...
src/io.ts
浏览文件 @
bdcb37e7
...
...
@@ -80,8 +80,8 @@ export class Io {
// this.purpose('offline')
// this.targetState('disconnected')
// this.currentState('disconnected')
this
.
state
.
target
(
'
offline
'
)
this
.
state
.
current
(
'
offline
'
)
//
this.state.target('offline')
//
this.state.current('offline')
}
// // targetState : 'connected' | 'disconnected'
...
...
src/puppet-web/browser.ts
浏览文件 @
bdcb37e7
...
...
@@ -46,8 +46,8 @@ export class Browser extends EventEmitter {
// this.targetState('close')
// this.currentState('close')
this
.
state
.
target
(
'
close
'
)
this
.
state
.
current
(
'
close
'
)
//
this.state.target('close')
//
this.state.current('close')
this
.
driver
=
new
BrowserDriver
(
this
.
setting
.
head
)
this
.
cookie
=
new
BrowserCookie
(
this
.
driver
,
this
.
setting
.
sessionFile
)
...
...
src/puppet.ts
浏览文件 @
bdcb37e7
...
...
@@ -47,8 +47,8 @@ export abstract class Puppet extends EventEmitter implements Sayable {
// this.targetState('dead')
// this.currentState('dead')
this
.
state
.
target
(
'
dead
'
)
this
.
state
.
current
(
'
dead
'
)
//
this.state.target('dead')
//
this.state.current('dead')
}
// targetState : 'live' | 'dead'
...
...
src/state-monitor.spec.ts
浏览文件 @
bdcb37e7
...
...
@@ -15,8 +15,11 @@ import test from 'ava'
import
StateMonitor
from
'
./state-monitor
'
test
(
'
StateMonitor smoking test
'
,
t
=>
{
const
CLIENT_NAME
=
'
StateMonitorTest
'
const
sm
=
new
StateMonitor
<
'
A
'
,
'
B
'
>
(
CLIENT_NAME
,
'
A
'
)
t
.
is
(
sm
.
client
(),
CLIENT_NAME
,
'
should get the same client name as init
'
)
const
sm
=
new
StateMonitor
<
'
A
'
,
'
B
'
>
(
'
SmokingTest
'
,
'
A
'
)
t
.
is
(
sm
.
current
(),
'
A
'
,
'
current should be A
'
)
t
.
is
(
sm
.
target
(),
'
A
'
,
'
target should be A
'
)
t
.
true
(
sm
.
stable
(),
'
should be stable
'
)
...
...
@@ -45,7 +48,7 @@ test('StateMonitor smoking test', t => {
})
test
(
'
StateMonitor stable
'
,
t
=>
{
const
sm
=
new
StateMonitor
<
'
A
'
,
'
B
'
>
(
'
S
moking
Test
'
,
'
A
'
)
const
sm
=
new
StateMonitor
<
'
A
'
,
'
B
'
>
(
'
S
tateMonitor
Test
'
,
'
A
'
)
sm
.
current
(
'
B
'
)
t
.
true
(
sm
.
stable
(),
'
should be stable
'
)
...
...
src/state-monitor.ts
浏览文件 @
bdcb37e7
...
...
@@ -21,8 +21,8 @@ export class StateMonitor <A, B>{
private
_current
:
A
|
B
private
_stable
:
boolean
constructor
(
private
client
:
string
,
initState
:
A
|
B
)
{
log
.
verbose
(
'
StateMonitor
'
,
'
constructor(%s, %s)
'
,
client
,
initState
)
constructor
(
private
_
client
:
string
,
initState
:
A
|
B
)
{
log
.
verbose
(
'
StateMonitor
'
,
'
constructor(%s, %s)
'
,
_
client
,
initState
)
this
.
_target
=
initState
this
.
_current
=
initState
...
...
@@ -35,13 +35,13 @@ export class StateMonitor <A, B>{
public
target
(
newState
?:
A
|
B
):
A
|
B
{
if
(
newState
)
{
log
.
verbose
(
'
StateMonitor
'
,
'
%s.state.target(%s) from %s
'
,
this
.
client
,
this
.
_
client
,
newState
,
this
.
_target
)
this
.
_target
=
newState
}
else
{
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.target() is %s
'
,
this
.
client
,
this
.
_target
)
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.target() is %s
'
,
this
.
_
client
,
this
.
_target
)
}
return
this
.
_target
}
...
...
@@ -53,7 +53,7 @@ export class StateMonitor <A, B>{
public
current
(
newState
?:
A
|
B
,
stable
=
true
):
A
|
B
{
if
(
newState
)
{
log
.
verbose
(
'
StateMonitor
'
,
'
%s.state.current(%s, %s) from (%s, %s)
'
,
this
.
client
,
this
.
_
client
,
newState
,
stable
,
this
.
_current
,
this
.
_stable
)
...
...
@@ -61,7 +61,7 @@ export class StateMonitor <A, B>{
&&
stable
===
false
// warn for inprocess current state change twice, mostly like a logic bug outside
)
{
log
.
warn
(
'
StateMonitor
'
,
'
%s.state.current(%s, %s) called but there are already in the same state
'
,
this
.
client
,
this
.
_
client
,
newState
,
stable
)
const
e
=
new
Error
(
'
current unchange
'
)
...
...
@@ -70,7 +70,7 @@ export class StateMonitor <A, B>{
this
.
_current
=
newState
this
.
_stable
=
stable
}
else
{
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.current() is %s
'
,
this
.
client
,
this
.
_current
)
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.current() is %s
'
,
this
.
_
client
,
this
.
_current
)
}
return
this
.
_current
}
...
...
@@ -79,7 +79,7 @@ export class StateMonitor <A, B>{
* does the current state be stable(not inprocess)?
*/
public
stable
()
{
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.stable() is %s
'
,
this
.
client
,
this
.
_stable
)
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.stable() is %s
'
,
this
.
_
client
,
this
.
_stable
)
return
this
.
_stable
}
...
...
@@ -87,9 +87,16 @@ export class StateMonitor <A, B>{
* does the current state be inprocess(not stable)?
*/
public
inprocess
()
{
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.inprocess() is %s
'
,
this
.
client
,
!
this
.
_stable
)
log
.
silly
(
'
StateMonitor
'
,
'
%s.state.inprocess() is %s
'
,
this
.
_
client
,
!
this
.
_stable
)
return
!
this
.
_stable
}
/**
* get the client name
*/
public
client
()
{
return
this
.
_client
}
}
export
default
StateMonitor
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录