@alepha/devtools 0.11.3 → 0.11.5
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/index.d.ts +261 -259
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -1346
- package/dist/index.js.map +1 -1
- package/package.json +26 -16
- package/src/DevCollectorProvider.ts +29 -29
- package/src/index.ts +4 -1
- package/src/ui/AppRouter.tsx +61 -0
- package/src/ui/DevLogs.tsx +143 -0
- package/src/ui/main.ts +4 -0
- package/src/ui/styles.css +7 -0
- package/src/ui/wotfardregular/stylesheet.css +12 -0
- package/src/ui/wotfardregular/wotfard-regular-webfont.eot +0 -0
- package/src/ui/wotfardregular/wotfard-regular-webfont.ttf +0 -0
- package/src/ui/wotfardregular/wotfard-regular-webfont.woff2 +0 -0
- package/src/constants/ui.ts +0 -1317
- package/src/schemas/DevLogEntry.ts +0 -11
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { t } from "@alepha/core";
|
|
2
|
+
import { type LogEntry, logEntrySchema } from "@alepha/logger";
|
|
3
|
+
import { useAction, useInject } from "@alepha/react";
|
|
4
|
+
import { useI18n } from "@alepha/react-i18n";
|
|
5
|
+
import { HttpClient } from "@alepha/server";
|
|
6
|
+
import { DataTable, Flex, Text } from "@alepha/ui";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
|
|
9
|
+
const DevLogs = () => {
|
|
10
|
+
const http = useInject(HttpClient);
|
|
11
|
+
const [logs, setLog] = useState<LogEntry[]>([]);
|
|
12
|
+
const { l } = useI18n();
|
|
13
|
+
|
|
14
|
+
useAction(
|
|
15
|
+
{
|
|
16
|
+
runOnInit: true,
|
|
17
|
+
runEvery: [10, "seconds"],
|
|
18
|
+
handler: async () => {
|
|
19
|
+
setLog(
|
|
20
|
+
await http
|
|
21
|
+
.fetch("/devtools/api/logs", {
|
|
22
|
+
schema: {
|
|
23
|
+
response: t.array(logEntrySchema),
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
.then(({ data }) => data),
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
[],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const renderLevel = (level: string) => {
|
|
34
|
+
switch (level.toLowerCase()) {
|
|
35
|
+
case "error":
|
|
36
|
+
return (
|
|
37
|
+
<Text ff={"monospace"} c="red">
|
|
38
|
+
{level.slice(0, 5)}
|
|
39
|
+
</Text>
|
|
40
|
+
);
|
|
41
|
+
case "warn":
|
|
42
|
+
return (
|
|
43
|
+
<Text ff={"monospace"} c="orange">
|
|
44
|
+
{level.slice(0, 5)}
|
|
45
|
+
</Text>
|
|
46
|
+
);
|
|
47
|
+
case "info":
|
|
48
|
+
return (
|
|
49
|
+
<Text ff={"monospace"} c="green">
|
|
50
|
+
{level.slice(0, 5)}
|
|
51
|
+
</Text>
|
|
52
|
+
);
|
|
53
|
+
case "debug":
|
|
54
|
+
return (
|
|
55
|
+
<Text ff={"monospace"} c="grape">
|
|
56
|
+
{level.slice(0, 5)}
|
|
57
|
+
</Text>
|
|
58
|
+
);
|
|
59
|
+
case "trace":
|
|
60
|
+
return (
|
|
61
|
+
<Text ff={"monospace"} c="dimmed">
|
|
62
|
+
{level.slice(0, 5)}
|
|
63
|
+
</Text>
|
|
64
|
+
);
|
|
65
|
+
default:
|
|
66
|
+
return <Text>{level}</Text>;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Flex>
|
|
72
|
+
<DataTable
|
|
73
|
+
tableProps={{
|
|
74
|
+
horizontalSpacing: "xs",
|
|
75
|
+
verticalSpacing: 0,
|
|
76
|
+
}}
|
|
77
|
+
tableTrProps={(item) => {
|
|
78
|
+
if (item.level.toLowerCase() === "error") {
|
|
79
|
+
return {
|
|
80
|
+
bg: "rgba(255,0,0,0.1)",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (item.level.toLowerCase() === "warn") {
|
|
84
|
+
return {
|
|
85
|
+
bg: "rgba(255,153,0,0.1)",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {};
|
|
89
|
+
}}
|
|
90
|
+
items={logs}
|
|
91
|
+
columns={{
|
|
92
|
+
timestamp: {
|
|
93
|
+
label: "Tme",
|
|
94
|
+
value: (item) => (
|
|
95
|
+
<Text c={"dimmed"} size={"xs"}>
|
|
96
|
+
{l(item.timestamp, {
|
|
97
|
+
date: "HH:mm:ss.SSS",
|
|
98
|
+
})}
|
|
99
|
+
</Text>
|
|
100
|
+
),
|
|
101
|
+
},
|
|
102
|
+
level: {
|
|
103
|
+
label: "Lvl",
|
|
104
|
+
value: (item) => renderLevel(item.level),
|
|
105
|
+
},
|
|
106
|
+
context: {
|
|
107
|
+
label: "Ctx",
|
|
108
|
+
value: (item) =>
|
|
109
|
+
item.context && (
|
|
110
|
+
<Text ff={"monospace"} size={"xs"} c="dimmed">
|
|
111
|
+
{item.context.slice(0, 8)}
|
|
112
|
+
</Text>
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
service: {
|
|
116
|
+
label: "Srv",
|
|
117
|
+
value: (item) => (
|
|
118
|
+
<Flex align={"center"} justify={"end"}>
|
|
119
|
+
{item.module && (
|
|
120
|
+
<Text c="dimmed" size={"xs"}>
|
|
121
|
+
{item.module}.
|
|
122
|
+
</Text>
|
|
123
|
+
)}
|
|
124
|
+
<Text size={"sm"}>{item.service}</Text>
|
|
125
|
+
</Flex>
|
|
126
|
+
),
|
|
127
|
+
},
|
|
128
|
+
message: {
|
|
129
|
+
label: "Msg",
|
|
130
|
+
value: (item) => item.message.slice(0, 64),
|
|
131
|
+
},
|
|
132
|
+
data: {
|
|
133
|
+
label: "Dat",
|
|
134
|
+
value: (item) =>
|
|
135
|
+
item.data ? JSON.stringify(item.data, null, 2).slice(0, 32) : "",
|
|
136
|
+
},
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</Flex>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default DevLogs;
|
package/src/ui/main.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! Generated by Font Squirrel (https://www.fontsquirrel.com) on March 27, 2020 */
|
|
2
|
+
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: "wotfardregular";
|
|
5
|
+
src: url("wotfard-regular-webfont.eot");
|
|
6
|
+
src:
|
|
7
|
+
url("wotfard-regular-webfont.eot?#iefix") format("embedded-opentype"),
|
|
8
|
+
url("wotfard-regular-webfont.woff2") format("woff2"),
|
|
9
|
+
url("wotfard-regular-webfont.ttf") format("truetype");
|
|
10
|
+
font-weight: normal;
|
|
11
|
+
font-style: normal;
|
|
12
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|