@midwayjs/code-dye 3.11.10 → 3.11.12

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/dist/html.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare const foreach: (info: any, start: any, pi: any, level: any) => string;
2
+ export declare const callChain: (call: any) => string;
2
3
  export declare const toHTML: (info: any) => string;
3
4
  //# sourceMappingURL=html.d.ts.map
package/dist/html.js CHANGED
@@ -1,8 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toHTML = exports.foreach = void 0;
3
+ exports.toHTML = exports.callChain = exports.foreach = void 0;
4
+ function getInfoResult(info) {
5
+ if (info.end) {
6
+ return `<div class="infoBtn">返回值<div class="infoCard"><pre>${JSON.stringify(info.end.result, null, 2)}</pre></div></div>`;
7
+ }
8
+ else {
9
+ return '<div class="infoBtn">未结束</div>';
10
+ }
11
+ }
12
+ function getInfoTimeUse(info) {
13
+ if (info.end) {
14
+ return info.end.time - info.start.time;
15
+ }
16
+ else {
17
+ return new Date().getTime() - info.start.time;
18
+ }
19
+ }
4
20
  const foreach = (info, start, pi, level) => {
5
- const timeUse = info.end.time - info.start.time;
21
+ const timeUse = getInfoTimeUse(info);
6
22
  const timeDiff = info.start.time - start;
7
23
  const paths = info.paths.filter(path => {
8
24
  return !path.startsWith('/');
@@ -13,13 +29,13 @@ const foreach = (info, start, pi, level) => {
13
29
  <div class="infoText">${paths.join(' / ')}</div>
14
30
  <div class="moreInfo">
15
31
  <div class="infoBtn">入参<div class="infoCard"><pre>${JSON.stringify(info.start.args, null, 2)}</pre></div></div>
16
- <div class="infoBtn">返回值<div class="infoCard"><pre>${JSON.stringify(info.end.result, null, 2)}</pre></div></div>
32
+ ${getInfoResult(info)}
17
33
  </div>
18
34
  </div>
19
35
  <div class="timeContainer">
20
- <div class="time" style="width:${timeUse / pi}px;left: ${timeDiff / pi}px"><div class="timeValue">${timeUse} ms</div></div>
36
+ <div class="time ${info.end ? 'end' : 'not-end'}" style="width:${timeUse / pi}px;left: ${timeDiff / pi}px"><div class="timeValue">${timeUse} ms</div></div>
21
37
  </div>
22
-
38
+
23
39
  </div>
24
40
  <div class="child">
25
41
  <div class="childLine" style="left: ${(level - 1) * 24 + 12}px"></div>
@@ -32,13 +48,24 @@ const foreach = (info, start, pi, level) => {
32
48
  `;
33
49
  };
34
50
  exports.foreach = foreach;
35
- const toHTML = info => {
36
- const timeDiff = info.end.time - info.start.time;
51
+ const callChain = call => {
52
+ const timeDiff = call.end.time - call.start.time;
37
53
  let pi = timeDiff / 600;
38
54
  if (pi < 1) {
39
55
  pi = 1;
40
56
  }
41
57
  return `
58
+ <div>
59
+ <div>调用链路总耗时 ${timeDiff}ms<div>
60
+ <div>调用结果:<br /><pre>${JSON.stringify(call.end.result, null, 2)}</pre></div>
61
+ <hr />
62
+ <div style="padding: 12px;">${(0, exports.foreach)(call, call.start.time, pi, 1)}</div>
63
+ </div>
64
+ `;
65
+ };
66
+ exports.callChain = callChain;
67
+ const toHTML = info => {
68
+ return `
42
69
  <title>Midway CodeDye</title>
43
70
  <meta charset="utf-8" />
44
71
  <style>
@@ -82,7 +109,10 @@ const toHTML = info => {
82
109
  background-color: #66c;
83
110
  border-radius: 3px;
84
111
  }
85
-
112
+ .time.not-end {
113
+ background-color: #ddd;
114
+ }
115
+
86
116
  .timeValue {
87
117
  position: absolute;
88
118
  line-height: 16px;
@@ -124,11 +154,7 @@ const toHTML = info => {
124
154
  }
125
155
  </style>
126
156
  <h1>Midway CodeDye</h1><hr />
127
- <div>调用链路总耗时 ${timeDiff}ms<div>
128
- <div>调用结果:<br /><pre>${JSON.stringify(info.end.result, null, 2)}</pre></div>
129
- <hr />
130
- <div style="padding: 12px;">
131
- ${(0, exports.foreach)(info, info.start.time, pi, 1)}</div>
157
+ ${info.map(call => (0, exports.callChain)(call)).join('')}
132
158
  <hr /><a href="https://www.midwayjs.org/">Powered by Midway.js</a>
133
159
  `;
134
160
  };
@@ -62,7 +62,7 @@ let CodeDyeMW = class CodeDyeMW {
62
62
  }
63
63
  else if (outputType === 'html') {
64
64
  response.set('Content-Type', 'text/html');
65
- return (0, html_1.toHTML)(reqInfo.call[0]);
65
+ return (0, html_1.toHTML)(reqInfo.call);
66
66
  }
67
67
  else if (outputType === 'json') {
68
68
  return reqInfoJSON;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/code-dye",
3
- "version": "3.11.10",
3
+ "version": "3.11.12",
4
4
  "description": "Midway Code Dye Component",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "@midwayjs/core": "^3.11.6",
26
- "@midwayjs/express": "^3.11.10",
27
- "@midwayjs/faas": "^3.11.10",
28
- "@midwayjs/koa": "^3.11.10",
29
- "@midwayjs/mock": "^3.11.10",
30
- "@midwayjs/serverless-app": "^3.11.10",
31
- "@midwayjs/web": "^3.11.10"
25
+ "@midwayjs/core": "^3.11.11",
26
+ "@midwayjs/express": "^3.11.12",
27
+ "@midwayjs/faas": "^3.11.12",
28
+ "@midwayjs/koa": "^3.11.12",
29
+ "@midwayjs/mock": "^3.11.12",
30
+ "@midwayjs/serverless-app": "^3.11.12",
31
+ "@midwayjs/web": "^3.11.12"
32
32
  },
33
- "gitHead": "521c42cc4af8850b77c5cf1f040b7430a74db041"
33
+ "gitHead": "7454a59cd57e693a04e4c887535c9193354e2980"
34
34
  }