Skip to content

Commit afbd093

Browse files
Merge pull request #145 from gridaco/editor-console-feed
Editor console feed
2 parents 4b5052c + 5c338dd commit afbd093

50 files changed

Lines changed: 800 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

editor-packages/editor-debugger/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./window-console-feed";
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React, { useEffect, useState } from "react";
2+
import { Console, Hook, Unhook } from "@code-editor/console-feed";
3+
4+
export function WindowConsoleFeed({ style }: { style?: React.CSSProperties }) {
5+
const [logs, setLogs] = useState([]);
6+
7+
useEffect(() => {
8+
// run once
9+
Hook(
10+
window.console,
11+
(log) => setLogs((currLogs) => [...currLogs, log]),
12+
false
13+
);
14+
return () => {
15+
Unhook(window.console as any);
16+
};
17+
}, []);
18+
19+
return (
20+
<div style={style}>
21+
<Console logs={logs} variant="dark" />
22+
</div>
23+
);
24+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from "./tab";
2+
export * from "./tab-badge";
3+
export * from "./console-feed";
4+
export * from "./visualization";
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from "react";
2+
import styled from "@emotion/styled";
3+
4+
const bgcolortypemap = {
5+
default: "rgba(255, 255, 255, 0.1)",
6+
warning: "rgba(255, 230, 0, 0.1)",
7+
error: "rgba(255, 0, 0, 0.1)",
8+
};
9+
10+
export function TabBadge({
11+
type = "default",
12+
value,
13+
}: {
14+
type?: "default" | "warning" | "error";
15+
value: string | number;
16+
}) {
17+
const background = bgcolortypemap[type];
18+
19+
if (value === undefined || value === null) {
20+
return <></>;
21+
}
22+
23+
return (
24+
<BaseDevtoolsTabBadge background={background}>
25+
<Value>{value}</Value>
26+
</BaseDevtoolsTabBadge>
27+
);
28+
}
29+
30+
const Value = styled.span`
31+
color: rgb(151, 151, 151);
32+
text-overflow: ellipsis;
33+
font-size: 10px;
34+
font-family: Inter, sans-serif;
35+
font-weight: 400;
36+
text-align: center;
37+
`;
38+
39+
const BaseDevtoolsTabBadge = styled.div<{ background: string }>`
40+
display: flex;
41+
justify-content: center;
42+
flex-direction: column;
43+
align-items: center;
44+
flex: none;
45+
gap: 10px;
46+
border-radius: 50%;
47+
width: 18px;
48+
height: 18px;
49+
background-color: ${(p) => p.background};
50+
box-sizing: border-box;
51+
padding: 10px;
52+
`;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from "react";
2+
import styled from "@emotion/styled";
3+
import { TabBadge } from "../tab-badge";
4+
5+
export function DevtoolsTab({
6+
label,
7+
badge,
8+
selected,
9+
onTap,
10+
}: {
11+
selected?: boolean;
12+
label: string;
13+
badge?: string | number;
14+
onTap?: () => void;
15+
}) {
16+
return (
17+
<TabBase onClick={onTap}>
18+
<Label data-selected={selected}>{label}</Label>
19+
<TabBadge value={badge} />
20+
</TabBase>
21+
);
22+
}
23+
24+
const TabBase = styled.div`
25+
cursor: pointer;
26+
user-select: none;
27+
display: flex;
28+
justify-content: flex-start;
29+
flex-direction: row;
30+
align-items: center;
31+
gap: 8px;
32+
box-sizing: border-box;
33+
`;
34+
35+
const Label = styled.span`
36+
color: rgb(151, 151, 151);
37+
text-overflow: ellipsis;
38+
font-size: 12px;
39+
font-family: Inter, sans-serif;
40+
font-weight: 400;
41+
text-align: left;
42+
43+
&:hover {
44+
color: white;
45+
}
46+
47+
&[data-selected="true"] {
48+
color: white;
49+
}
50+
`;

editor-packages/editor-debugger/components/visualization/README.md renamed to editor-packages/editor-devtools/components/visualization/README.md

File renamed without changes.

editor-packages/editor-debugger/components/visualization/index.ts renamed to editor-packages/editor-devtools/components/visualization/index.ts

File renamed without changes.

editor-packages/editor-debugger/components/visualization/json-visualization/json-tree.tsx renamed to editor-packages/editor-devtools/components/visualization/json-visualization/json-tree.tsx

File renamed without changes.

editor-packages/editor-debugger/components/visualization/node-visualization/index.ts renamed to editor-packages/editor-devtools/components/visualization/node-visualization/index.ts

File renamed without changes.

0 commit comments

Comments
 (0)