Skip to content

Commit 896c16a

Browse files
committed
Remove console-feed dependency
1 parent 4c726d1 commit 896c16a

File tree

6 files changed

+2600
-2994
lines changed

6 files changed

+2600
-2994
lines changed

package-lock.json

Lines changed: 2560 additions & 2913 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"browserify-zlib": "^0.2.0",
2525
"buffer": "^6.0.3",
2626
"clsx": "^1.1.1",
27-
"console-feed": "^3.4.3",
2827
"d3": "^6.2.0",
2928
"fengari-web": "^0.1.4",
3029
"lua-types": "^2.13.1",

src/pages/play/Playground.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useColorMode } from "@docusaurus/theme-common";
22
import clsx from "clsx";
3-
import { Console as ConsoleFeed } from "console-feed";
43
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
54
import { JSONTree } from "react-json-tree";
65
import MonacoEditor from "react-monaco-editor";
@@ -11,7 +10,7 @@ import { getInitialCode, updateCodeHistory } from "./code";
1110
import { ConsoleMessage, executeLua } from "./execute";
1211
import { monaco, useMonacoTheme } from "./monaco";
1312
import styles from "./styles.module.scss";
14-
import { consoleFeedTheme, jsonTreeTheme } from "./themes";
13+
import { jsonTreeTheme } from "./themes";
1514
import type { CustomTypeScriptWorker } from "./ts.worker";
1615

1716
enum PanelKind {
@@ -122,24 +121,32 @@ function LuaAST({ ast }: { ast: object }) {
122121
);
123122
}
124123

124+
function formatLuaOutputData(data: any): string {
125+
return data.toString();
126+
}
127+
128+
function consoleOutputRowClass(data: ConsoleMessage) {
129+
let rowClass = styles.luaOutputTerminalRow;
130+
131+
if (data.method === "error") {
132+
rowClass += " " + styles.luaOutputTerminalError;
133+
}
134+
135+
return rowClass;
136+
}
137+
125138
function LuaOutput() {
126-
const { colorMode } = useColorMode();
127-
const isDarkTheme = colorMode === "dark";
128139
const { results } = useContext(EditorContext);
129140

130141
return (
131142
<div className={styles.luaOutput}>
132143
<div className={styles.luaOutputLineNumbers}>{">_"}</div>
133144
<div className={styles.luaOutputTerminal}>
134-
<ConsoleFeed
135-
logs={results.map((r, i) => ({
136-
id: i.toString(),
137-
data: r.data?.map((d) => d.toString()) ?? [],
138-
method: r.method,
139-
}))}
140-
variant={isDarkTheme ? "dark" : "light"}
141-
styles={consoleFeedTheme(isDarkTheme)}
142-
/>
145+
{results.map((r, i) => (
146+
<div className={consoleOutputRowClass(r)} key={i}>
147+
{r.data.map(formatLuaOutputData).join("\t")}
148+
</div>
149+
))}
143150
</div>
144151
</div>
145152
);

src/pages/play/execute/fengari.worker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import setupCode from "!!raw-loader!./setup.lua";
2-
import type { Message as ConsoleMessage } from "console-feed/lib/definitions/Console";
32
import { interop, lauxlib, lua, lualib, to_luastring } from "fengari-web";
43

5-
export type { ConsoleMessage };
4+
export interface ConsoleMessage {
5+
data: unknown[];
6+
method: string;
7+
}
68

79
const workerContext = globalThis as typeof globalThis & { printStream: any[] };
810

src/pages/play/styles.module.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ $output-height: 180px;
106106
overflow-y: auto;
107107
}
108108

109+
.luaOutputTerminalRow {
110+
border-bottom: 1px solid rgba(128, 128, 128, 0.35);
111+
padding: 6px 10px 6px 30px;
112+
box-sizing: border-box;
113+
font-family: Menlo, monospace;
114+
font-size: 13px;
115+
white-space: pre-wrap;
116+
}
117+
118+
.luaOutputTerminalError {
119+
color: rgb(254, 127, 127);
120+
background-color: rgb(40, 0, 0);
121+
border-top: 1px solid rgb(91, 0, 0);
122+
border-bottom: 1px solid rgb(91, 0, 0);
123+
}
124+
109125
@media only screen and (max-width: 996px) {
110126
.content {
111127
flex-flow: column;

src/pages/play/themes.tsx

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,68 +19,3 @@ export const jsonTreeTheme = {
1919
base0E: "#ae81ff",
2020
base0F: "#cc6633",
2121
};
22-
23-
// Based on https://github.com/codesandbox/codesandbox-client/blob/61f01ff0d231057826184315039b020fe85d81fa/packages/app/src/app/components/Preview/DevTools/Console/elements.ts#L58
24-
export const consoleFeedTheme = (isDarkTheme: boolean) => ({
25-
PADDING: "0.4rem 1.5rem 0.4rem 0px",
26-
27-
LOG_ICON: "",
28-
LOG_BORDER: "#80808059",
29-
LOG_ICON_HEIGHT: "26px",
30-
LOG_ICON_WIDTH: "1em",
31-
32-
LOG_COMMAND_ICON: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='rgba(255, 255, 255, 0.8)' viewBox='0 0 40 40'%3e%3cpath d='M16.6 10l10 10-10 10-2.3-2.3L22 20l-7.7-7.7z'/%3e%3c/svg%3e")`,
33-
LOG_RESULT_ICON: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='rgba(255, 255, 255, 0.8)' preserveAspectRatio='xMidYMid meet' viewBox='0 0 40 40'%3e%3cg%3e%3cpath d='m22 30.7q0 0.3-0.2 0.5l-1.1 1.1q-0.3 0.3-0.6 0.3t-0.5-0.3l-10.4-10.4q-0.2-0.2-0.2-0.5t0.2-0.5l10.4-10.4q0.3-0.2 0.5-0.2t0.6 0.2l1.1 1.1q0.2 0.3 0.2 0.5t-0.2 0.6l-8.8 8.7 8.8 8.8q0.2 0.2 0.2 0.5z m8.6 0q0 0.3-0.3 0.5l-1.1 1.1q-0.2 0.3-0.5 0.3t-0.5-0.3l-10.4-10.4q-0.2-0.2-0.2-0.5t0.2-0.5l10.4-10.4q0.2-0.2 0.5-0.2t0.5 0.2l1.1 1.1q0.3 0.3 0.3 0.5t-0.3 0.6l-8.7 8.7 8.7 8.8q0.3 0.2 0.3 0.5z'%3e%3c/path%3e%3c/g%3e%3c/svg%3e")`,
34-
35-
LOG_WARN_COLOR: "rgb(245, 211, 150)",
36-
LOG_WARN_BACKGROUND: "#332A00",
37-
LOG_WARN_BORDER: "#665500",
38-
LOG_WARN_ICON: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23F5D396' viewBox='0 0 40 40'%3e%3cpath d='M21.6 23.4v-6.8h-3.2v6.8h3.2zm0 6.6v-3.4h-3.2V30h3.2zm-20 5L20 3.4 38.4 35H1.6z'/%3e%3c/svg%3e")`,
39-
40-
LOG_ERROR_COLOR: "rgb(254, 127, 127)",
41-
LOG_ERROR_BACKGROUND: "#280000",
42-
LOG_ERROR_BORDER: "#5B0000",
43-
LOG_ERROR_ICON: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23FE7F7F' viewBox='0 0 40 40'%3e%3cpath d='M21.6 21.6v-10h-3.2v10h3.2zm0 6.8V25h-3.2v3.4h3.2zM20 3.4a16.6 16.6 0 1 1 0 33.2 16.6 16.6 0 1 1 0-33.2z'/%3e%3c/svg%3e")`,
44-
45-
BASE_FONT_FAMILY: "Menlo, monospace",
46-
BASE_FONT_SIZE: "13px",
47-
BASE_LINE_HEIGHT: "18px",
48-
49-
BASE_BACKGROUND_COLOR: "rgba(0, 0, 0, 0)",
50-
LOG_COLOR: isDarkTheme ? "rgb(213, 213, 213)" : "rgb(52, 52, 52)",
51-
52-
OBJECT_NAME_COLOR: "#40A9F3",
53-
OBJECT_VALUE_NULL_COLOR: "rgb(127, 127, 127)",
54-
OBJECT_VALUE_UNDEFINED_COLOR: "rgb(127, 127, 127)",
55-
OBJECT_VALUE_REGEXP_COLOR: "#fac863",
56-
OBJECT_VALUE_STRING_COLOR: "#fac863",
57-
OBJECT_VALUE_SYMBOL_COLOR: "#fac863",
58-
OBJECT_VALUE_NUMBER_COLOR: "hsl(252, 100%, 75%)",
59-
OBJECT_VALUE_BOOLEAN_COLOR: "hsl(252, 100%, 75%)",
60-
OBJECT_VALUE_FUNCTION_KEYWORD_COLOR: "rgb(242, 85, 217)",
61-
62-
HTML_TAG_COLOR: "rgb(93, 176, 215)",
63-
HTML_TAGNAME_COLOR: "rgb(93, 176, 215)",
64-
HTML_TAGNAME_TEXT_TRANSFORM: "lowercase",
65-
HTML_ATTRIBUTE_NAME_COLOR: "rgb(155, 187, 220)",
66-
HTML_ATTRIBUTE_VALUE_COLOR: "rgb(242, 151, 102)",
67-
HTML_COMMENT_COLOR: "rgb(137, 137, 137)",
68-
HTML_DOCTYPE_COLOR: "rgb(192, 192, 192)",
69-
70-
ARROW_COLOR: "rgb(145, 145, 145)",
71-
ARROW_MARGIN_RIGHT: 3,
72-
ARROW_FONT_SIZE: 11,
73-
74-
TREENODE_FONT_FAMILY: "Menlo, monospace",
75-
TREENODE_FONT_SIZE: "13px",
76-
TREENODE_LINE_HEIGHT: "16px",
77-
TREENODE_PADDING_LEFT: 12,
78-
79-
TABLE_BORDER_COLOR: "rgb(85, 85, 85)",
80-
TABLE_TH_BACKGROUND_COLOR: "rgb(44, 44, 44)",
81-
TABLE_TH_HOVER_COLOR: "rgb(48, 48, 48)",
82-
TABLE_SORT_ICON_COLOR: "black",
83-
TABLE_DATA_BACKGROUND_IMAGE:
84-
"linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(51, 139, 255, 0.0980392) 50%, rgba(51, 139, 255, 0.0980392))",
85-
TABLE_DATA_BACKGROUND_SIZE: "128px 32px",
86-
});

0 commit comments

Comments
 (0)