@eggjs/onerror 4.0.0-beta.19 → 4.0.0-beta.21

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.
@@ -1,158 +1,154 @@
1
- import { OnerrorError } from "koa-onerror";
2
- import { StackFrame } from "stack-trace";
3
- import { Context } from "egg";
4
-
5
- //#region src/lib/error_view.d.ts
6
- interface FrameSource {
7
- pre: string[];
8
- line: string;
9
- post: string[];
1
+ import { type StackFrame } from 'stack-trace';
2
+ import type { OnerrorError } from 'koa-onerror';
3
+ import type { Context } from 'egg';
4
+ export interface FrameSource {
5
+ pre: string[];
6
+ line: string;
7
+ post: string[];
10
8
  }
11
- interface Frame extends StackFrame {
12
- context?: FrameSource;
9
+ export interface Frame extends StackFrame {
10
+ context?: FrameSource;
13
11
  }
14
- declare class ErrorView {
15
- ctx: Context;
16
- error: OnerrorError;
17
- request: Context['request'];
18
- app: Context['app'];
19
- assets: Map<string, string>;
20
- viewTemplate: string;
21
- codeContext: number;
22
- _filterHeaders: string[];
23
- constructor(ctx: Context, error: OnerrorError, template: string);
24
- /**
25
- * get html error page
26
- *
27
- * @return {String} html page
28
- */
29
- toHTML(): string;
30
- /**
31
- * compile view
32
- *
33
- * @param {String} tpl - template
34
- * @param {Object} locals - data used by template
35
- */
36
- compileView(tpl: string, locals: Record<string, unknown>): string;
37
- /**
38
- * check if the frame is node native file.
39
- *
40
- * @param {Frame} frame - current frame
41
- */
42
- isNode(frame: Frame): boolean;
43
- /**
44
- * check if the frame is app modules.
45
- *
46
- * @param {Object} frame - current frame
47
- */
48
- isApp(frame: Frame): boolean;
49
- /**
50
- * cache file asserts
51
- *
52
- * @param {String} key - assert key
53
- * @param {String} value - assert content
54
- */
55
- setAssets(key: string, value: string): void;
56
- /**
57
- * get cache file asserts
58
- *
59
- * @param {String} key - assert key
60
- */
61
- getAssets(key: string): string | undefined;
62
- /**
63
- * get frame source
64
- *
65
- * @param {Object} frame - current frame
66
- */
67
- getFrameSource(frame: StackFrame): FrameSource;
68
- /**
69
- * parse error and return frame stack
70
- */
71
- parseError(): Frame[];
72
- /**
73
- * get stack context
74
- *
75
- * @param {Object} frame - current frame
76
- */
77
- getContext(frame: Frame): {
78
- start?: undefined;
79
- pre?: undefined;
80
- line?: undefined;
81
- post?: undefined;
82
- } | {
83
- start: number;
84
- pre: string;
85
- line: string;
86
- post: string;
87
- };
88
- /**
89
- * get frame classes, let view identify the frame
90
- *
91
- * @param {any} frame - current frame
92
- * @param {any} index - current index
93
- */
94
- getFrameClasses(frame: Frame, index: number): string;
95
- /**
96
- * serialize frame and return meaningful data
97
- *
98
- * @param {Object} frame - current frame
99
- */
100
- serializeFrame(frame: Frame): {
101
- extname: string;
102
- file: string;
103
- method: string;
104
- line: number;
105
- column: number;
106
- context: {
107
- start?: undefined;
108
- pre?: undefined;
109
- line?: undefined;
110
- post?: undefined;
12
+ export declare class ErrorView {
13
+ ctx: Context;
14
+ error: OnerrorError;
15
+ request: Context['request'];
16
+ app: Context['app'];
17
+ assets: Map<string, string>;
18
+ viewTemplate: string;
19
+ codeContext: number;
20
+ _filterHeaders: string[];
21
+ constructor(ctx: Context, error: OnerrorError, template: string);
22
+ /**
23
+ * get html error page
24
+ *
25
+ * @return {String} html page
26
+ */
27
+ toHTML(): string;
28
+ /**
29
+ * compile view
30
+ *
31
+ * @param {String} tpl - template
32
+ * @param {Object} locals - data used by template
33
+ */
34
+ compileView(tpl: string, locals: Record<string, unknown>): string;
35
+ /**
36
+ * check if the frame is node native file.
37
+ *
38
+ * @param {Frame} frame - current frame
39
+ */
40
+ isNode(frame: Frame): boolean;
41
+ /**
42
+ * check if the frame is app modules.
43
+ *
44
+ * @param {Object} frame - current frame
45
+ */
46
+ isApp(frame: Frame): boolean;
47
+ /**
48
+ * cache file asserts
49
+ *
50
+ * @param {String} key - assert key
51
+ * @param {String} value - assert content
52
+ */
53
+ setAssets(key: string, value: string): void;
54
+ /**
55
+ * get cache file asserts
56
+ *
57
+ * @param {String} key - assert key
58
+ */
59
+ getAssets(key: string): string | undefined;
60
+ /**
61
+ * get frame source
62
+ *
63
+ * @param {Object} frame - current frame
64
+ */
65
+ getFrameSource(frame: StackFrame): FrameSource;
66
+ /**
67
+ * parse error and return frame stack
68
+ */
69
+ parseError(): Frame[];
70
+ /**
71
+ * get stack context
72
+ *
73
+ * @param {Object} frame - current frame
74
+ */
75
+ getContext(frame: Frame): {
76
+ start?: undefined;
77
+ pre?: undefined;
78
+ line?: undefined;
79
+ post?: undefined;
111
80
  } | {
112
- start: number;
113
- pre: string;
114
- line: string;
115
- post: string;
81
+ start: number;
82
+ pre: string;
83
+ line: string;
84
+ post: string;
85
+ };
86
+ /**
87
+ * get frame classes, let view identify the frame
88
+ *
89
+ * @param {any} frame - current frame
90
+ * @param {any} index - current index
91
+ */
92
+ getFrameClasses(frame: Frame, index: number): string;
93
+ /**
94
+ * serialize frame and return meaningful data
95
+ *
96
+ * @param {Object} frame - current frame
97
+ */
98
+ serializeFrame(frame: Frame): {
99
+ extname: string;
100
+ file: string;
101
+ method: string;
102
+ line: number;
103
+ column: number;
104
+ context: {
105
+ start?: undefined;
106
+ pre?: undefined;
107
+ line?: undefined;
108
+ post?: undefined;
109
+ } | {
110
+ start: number;
111
+ pre: string;
112
+ line: string;
113
+ post: string;
114
+ };
115
+ classes: string;
116
+ };
117
+ /**
118
+ * serialize base data
119
+ *
120
+ * @param {Object} stack - frame stack
121
+ * @param {Function} frameFormatter - frame formatter function
122
+ */
123
+ serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
124
+ code: any;
125
+ message: string;
126
+ name: string;
127
+ status: number;
128
+ frames: any[];
129
+ };
130
+ /**
131
+ * serialize request object
132
+ */
133
+ serializeRequest(): {
134
+ url: string;
135
+ httpVersion: string;
136
+ method: string;
137
+ connection: string | undefined;
138
+ headers: {
139
+ key: string;
140
+ value: string | string[] | undefined;
141
+ }[];
142
+ cookies: {
143
+ key: string;
144
+ value: string | undefined;
145
+ }[];
146
+ };
147
+ /**
148
+ * serialize app info object
149
+ */
150
+ serializeAppInfo(): {
151
+ baseDir: string;
152
+ config: string;
116
153
  };
117
- classes: string;
118
- };
119
- /**
120
- * serialize base data
121
- *
122
- * @param {Object} stack - frame stack
123
- * @param {Function} frameFormatter - frame formatter function
124
- */
125
- serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
126
- code: any;
127
- message: string;
128
- name: string;
129
- status: number;
130
- frames: any[];
131
- };
132
- /**
133
- * serialize request object
134
- */
135
- serializeRequest(): {
136
- url: string;
137
- httpVersion: string;
138
- method: string;
139
- connection: string | undefined;
140
- headers: {
141
- key: string;
142
- value: string | string[] | undefined;
143
- }[];
144
- cookies: {
145
- key: string;
146
- value: string | undefined;
147
- }[];
148
- };
149
- /**
150
- * serialize app info object
151
- */
152
- serializeAppInfo(): {
153
- baseDir: string;
154
- config: string;
155
- };
156
154
  }
157
- //#endregion
158
- export { ErrorView, Frame, FrameSource };