-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevtools-formatter.ts
More file actions
61 lines (60 loc) · 1.9 KB
/
devtools-formatter.ts
File metadata and controls
61 lines (60 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { Endpoint } from "../lib/special-core-types/endpoint.ts";
import { Range } from "../lib/special-core-types/range.ts";
import { Ref } from "../refs/ref.ts";
// @ts-ignore devtoolsFormatters
globalThis.devtoolsFormatters = [
{
header(obj: unknown) {
if (obj instanceof Endpoint) {
return ["span", { style: "color: #58d452" }, obj.toString()];
} else if (obj instanceof Ref) {
return [
"span",
{},
[
"span",
{},
[
"span",
{ style: "color: #1279d5" },
"&mut ",
],
[
"span",
{},
// TODO: only proof of concept, syntax highlighting does not match JS
obj.value,
],
],
];
} else if (obj instanceof Range) {
return [
"span",
{},
[
"span",
{},
["span", { style: "color: #d57258" }, `${obj.start}`],
],
[
"span",
{},
["span", {}, `..`],
],
[
"span",
{},
["span", { style: "color: #d57258" }, `${obj.end}`],
],
];
}
return null; // fall back to default
},
hasBody(_: unknown) {
return false;
},
body(_: unknown) {
return null;
},
},
];