@eggjs/onerror 4.0.0-beta.35 → 4.0.0-beta.36

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,144 +1,148 @@
1
- import type { Context } from 'egg';
2
- import type { OnerrorError } from 'koa-onerror';
3
- import { type StackFrame } from 'stack-trace';
4
- export interface FrameSource {
5
- pre: string[];
6
- line: string;
7
- post: string[];
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[];
8
10
  }
9
- export interface Frame extends StackFrame {
10
- context?: FrameSource;
11
+ interface Frame extends StackFrame {
12
+ context?: FrameSource;
11
13
  }
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?: number;
77
- pre?: string;
78
- line?: string;
79
- post?: string;
80
- };
81
- /**
82
- * get frame classes, let view identify the frame
83
- *
84
- * @param {any} frame - current frame
85
- * @param {any} index - current index
86
- */
87
- getFrameClasses(frame: Frame, index: number): string;
88
- /**
89
- * serialize frame and return meaningful data
90
- *
91
- * @param {Object} frame - current frame
92
- */
93
- serializeFrame(frame: Frame): {
94
- extname: string;
95
- file: string;
96
- method: string | null;
97
- line: number | null;
98
- column: number | null;
99
- context: {
100
- start?: number;
101
- pre?: string;
102
- line?: string;
103
- post?: string;
104
- };
105
- classes: string;
106
- };
107
- /**
108
- * serialize base data
109
- *
110
- * @param {Object} stack - frame stack
111
- * @param {Function} frameFormatter - frame formatter function
112
- */
113
- serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
114
- code: any;
115
- message: string;
116
- name: string;
117
- status: number | undefined;
118
- frames: any[];
119
- };
120
- /**
121
- * serialize request object
122
- */
123
- serializeRequest(): {
124
- url: string;
125
- httpVersion: string;
126
- method: string;
127
- connection: string | string[] | undefined;
128
- headers: {
129
- key: string;
130
- value: string | string[] | undefined;
131
- }[];
132
- cookies: {
133
- key: string;
134
- value: string | undefined;
135
- }[];
136
- };
137
- /**
138
- * serialize app info object
139
- */
140
- serializeAppInfo(): {
141
- baseDir: string;
142
- config: string;
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?: number;
79
+ pre?: string;
80
+ line?: string;
81
+ post?: string;
82
+ };
83
+ /**
84
+ * get frame classes, let view identify the frame
85
+ *
86
+ * @param {any} frame - current frame
87
+ * @param {any} index - current index
88
+ */
89
+ getFrameClasses(frame: Frame, index: number): string;
90
+ /**
91
+ * serialize frame and return meaningful data
92
+ *
93
+ * @param {Object} frame - current frame
94
+ */
95
+ serializeFrame(frame: Frame): {
96
+ extname: string;
97
+ file: string;
98
+ method: string | null;
99
+ line: number | null;
100
+ column: number | null;
101
+ context: {
102
+ start?: number;
103
+ pre?: string;
104
+ line?: string;
105
+ post?: string;
143
106
  };
107
+ classes: string;
108
+ };
109
+ /**
110
+ * serialize base data
111
+ *
112
+ * @param {Object} stack - frame stack
113
+ * @param {Function} frameFormatter - frame formatter function
114
+ */
115
+ serializeData(stack: Frame[], frameFormatter: (frame: Frame, index: number) => any): {
116
+ code: any;
117
+ message: string;
118
+ name: string;
119
+ status: number | undefined;
120
+ frames: any[];
121
+ };
122
+ /**
123
+ * serialize request object
124
+ */
125
+ serializeRequest(): {
126
+ url: string;
127
+ httpVersion: string;
128
+ method: string;
129
+ connection: string | string[] | undefined;
130
+ headers: {
131
+ key: string;
132
+ value: string | string[] | undefined;
133
+ }[];
134
+ cookies: {
135
+ key: string;
136
+ value: string | undefined;
137
+ }[];
138
+ };
139
+ /**
140
+ * serialize app info object
141
+ */
142
+ serializeAppInfo(): {
143
+ baseDir: string;
144
+ config: string;
145
+ };
144
146
  }
147
+ //#endregion
148
+ export { ErrorView, Frame, FrameSource };