@fe-free/core 1.4.15 → 1.4.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 1.4.17
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: re
8
+ - @fe-free/tool@1.4.17
9
+
10
+ ## 1.4.16
11
+
12
+ ### Patch Changes
13
+
14
+ - feat: modify EditorLogs
15
+ - @fe-free/tool@1.4.16
16
+
3
17
  ## 1.4.15
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "1.4.15",
3
+ "version": "1.4.17",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -36,7 +36,7 @@
36
36
  "react-syntax-highlighter": "^15.5.0",
37
37
  "vanilla-jsoneditor": "^0.23.1",
38
38
  "zustand": "^4.5.4",
39
- "@fe-free/tool": "1.4.15"
39
+ "@fe-free/tool": "1.4.17"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@ant-design/pro-components": "^2.8.7",
@@ -42,6 +42,38 @@ export const Basic: Story = {
42
42
  message:
43
43
  'This is a debug log message. This is a debug log message This is a debug log message This is a debug log message This is a debug log message',
44
44
  },
45
+ {
46
+ timestamp: '2023-01-01 12:00:00',
47
+ message: 'This is an log message.',
48
+ },
49
+ {
50
+ level: 'info',
51
+ message: 'This is an log message.',
52
+ },
53
+ {
54
+ message: 'This is an log message.',
55
+ },
56
+ ],
57
+ },
58
+ render: (props) => (
59
+ <div style={{ width: '500px', height: '500px' }}>
60
+ <EditorLogs {...props} />
61
+ </div>
62
+ ),
63
+ };
64
+
65
+ export const Pure: Story = {
66
+ args: {
67
+ logs: [
68
+ {
69
+ message: 'This is an info log message.',
70
+ },
71
+ {
72
+ message: 'This is a warning log message.',
73
+ },
74
+ {
75
+ message: 'This is an error log message.',
76
+ },
45
77
  ],
46
78
  },
47
79
  render: (props) => (
@@ -6,19 +6,35 @@ import { Editor } from '../editor';
6
6
 
7
7
  interface EditorLogsProps {
8
8
  logs: {
9
- timestamp: string;
10
- level: 'info' | 'warn' | 'error' | 'system';
9
+ timestamp?: string;
10
+ level?: 'info' | 'warn' | 'error' | 'system';
11
11
  message: string;
12
12
  }[];
13
13
  }
14
14
 
15
15
  const EditorLogs: React.FC<EditorLogsProps> = ({ logs }) => {
16
- const formattedLogs = logs
17
- .map((log) => {
18
- const levelPadded = `[${log.level}]`.padEnd(8, ' ');
19
- return `${log.timestamp} ${levelPadded.toUpperCase()} ${log.message}`;
20
- })
21
- .join('\n');
16
+ const notPure = logs.find((item) => item.timestamp || item.level);
17
+
18
+ let formattedLogs = '';
19
+ if (notPure) {
20
+ formattedLogs = logs
21
+ .map((log) => {
22
+ const arr: string[] = [];
23
+
24
+ arr.push((log.timestamp || '').padEnd(19, ' '));
25
+
26
+ arr.push(`[${log.level || ''}]`.padEnd(8, ' ').toUpperCase());
27
+
28
+ if (log.message) {
29
+ arr.push(log.message);
30
+ }
31
+
32
+ return arr.join(' ');
33
+ })
34
+ .join('\n');
35
+ } else {
36
+ formattedLogs = logs.map((log) => log.message).join('\n');
37
+ }
22
38
 
23
39
  const logExtension = [
24
40
  StreamLanguage.define({