@leafer/debug 1.0.0-alpha.9 → 1.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/Debug.ts +9 -18
- package/src/Run.ts +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/debug",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta",
|
|
4
4
|
"description": "@leafer/debug",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/math": "1.0.0-
|
|
22
|
+
"@leafer/math": "1.0.0-beta"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-
|
|
25
|
+
"@leafer/interface": "1.0.0-beta"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/Debug.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { IObject } from '@leafer/interface'
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
export class Debug {
|
|
5
2
|
|
|
6
3
|
static enable: boolean
|
|
@@ -9,11 +6,9 @@ export class Debug {
|
|
|
9
6
|
static excludeList: string[] = []
|
|
10
7
|
|
|
11
8
|
// other
|
|
12
|
-
static __: IObject = {}
|
|
13
|
-
|
|
14
|
-
@debugAttr()
|
|
15
9
|
static showRepaint: boolean
|
|
16
|
-
|
|
10
|
+
static showHitView: boolean | string | string[]
|
|
11
|
+
static showBoundsView: boolean | string | string[]
|
|
17
12
|
|
|
18
13
|
public name: string
|
|
19
14
|
|
|
@@ -37,6 +32,7 @@ export class Debug {
|
|
|
37
32
|
this.excludeList = name
|
|
38
33
|
}
|
|
39
34
|
|
|
35
|
+
|
|
40
36
|
log(...messages: unknown[]): void {
|
|
41
37
|
if (D.enable) {
|
|
42
38
|
if (D.filterList.length && D.filterList.every(name => name !== this.name)) return
|
|
@@ -50,17 +46,12 @@ export class Debug {
|
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
error(...messages: unknown[]): void {
|
|
53
|
-
|
|
49
|
+
try {
|
|
50
|
+
throw new Error()
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error(this.name, ...messages, e)
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const D = Debug
|
|
58
|
-
|
|
59
|
-
function debugAttr(defaultValue?: unknown) {
|
|
60
|
-
return (target: IObject, key: string) => {
|
|
61
|
-
Object.defineProperty(target, key, {
|
|
62
|
-
get() { return target.enable ? target.__[key] : defaultValue },
|
|
63
|
-
set(value: unknown) { this.__[key] = value }
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
}
|
|
57
|
+
const D = Debug
|
package/src/Run.ts
CHANGED
|
@@ -33,9 +33,7 @@ export class Run {
|
|
|
33
33
|
static end(id: number, microsecond?: boolean): void {
|
|
34
34
|
const time = R.idMap[id]
|
|
35
35
|
const name = R.nameMap[id]
|
|
36
|
-
R.idMap[id] = undefined
|
|
37
|
-
R.nameMap[id] = undefined
|
|
38
|
-
R.nameToIdMap[name] = undefined
|
|
36
|
+
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined
|
|
39
37
|
|
|
40
38
|
if (microsecond) {
|
|
41
39
|
debug.log(name, performance.now() - time, 'µs')
|
|
@@ -46,7 +44,7 @@ export class Run {
|
|
|
46
44
|
|
|
47
45
|
static endOfName(name: string, microsecond?: boolean): void {
|
|
48
46
|
const id = R.nameToIdMap[name]
|
|
49
|
-
if (id) R.end(id, microsecond)
|
|
47
|
+
if (id !== undefined) R.end(id, microsecond)
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|