@ttsc/playground 0.25.0 → 0.26.0
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/LICENSE +21 -21
- package/package.json +3 -3
- package/src/react/ConsoleViewer.tsx +121 -121
- package/src/react/DependencyProgressModal.tsx +73 -73
- package/src/react/DiagnosticsPanel.tsx +74 -74
- package/src/react/ExamplePicker.tsx +93 -93
- package/src/react/LintPane.tsx +58 -58
- package/src/react/OptionsPanel.tsx +132 -132
- package/src/react/ResultViewer.tsx +75 -75
- package/src/react/SourceEditor.tsx +95 -95
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Jeongho Nam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jeongho Nam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/playground",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Reusable React + Web Worker scaffolding for in-browser ttsc playgrounds built on @ttsc/wasm.",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react": "^18.0.0",
|
|
40
40
|
"react-dom": "^18.0.0",
|
|
41
41
|
"tgrid": "^1.0.3",
|
|
42
|
-
"@ttsc/wasm": "^0.
|
|
42
|
+
"@ttsc/wasm": "^0.26.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@monaco-editor/react": "^4.6.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"rimraf": "^6.1.2",
|
|
53
53
|
"tgrid": "^1.0.3",
|
|
54
54
|
"typescript": "^7.0.2",
|
|
55
|
-
"@ttsc/wasm": "^0.
|
|
55
|
+
"@ttsc/wasm": "^0.26.0"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"ttsc",
|
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { JSX } from "react";
|
|
4
|
-
|
|
5
|
-
import type { IConsoleMessage } from "../structures/IConsoleMessage";
|
|
6
|
-
|
|
7
|
-
interface ConsoleViewerProps {
|
|
8
|
-
messages: IConsoleMessage[];
|
|
9
|
-
empty?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function ConsoleViewer({
|
|
13
|
-
messages,
|
|
14
|
-
empty = "No output yet. Click Execute to run the compiled JavaScript.",
|
|
15
|
-
}: ConsoleViewerProps) {
|
|
16
|
-
if (messages.length === 0)
|
|
17
|
-
return (
|
|
18
|
-
<div className="flex h-full w-full items-center justify-center px-4 text-center font-mono text-[11px] text-slate-400">
|
|
19
|
-
{empty}
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
return (
|
|
23
|
-
<div className="h-full w-full overflow-auto p-3 font-mono text-[12px] leading-snug">
|
|
24
|
-
{messages.map((msg, i) => (
|
|
25
|
-
<div
|
|
26
|
-
key={i}
|
|
27
|
-
className="flex gap-2 border-b border-[#d8e7f4] py-1 last:border-b-0"
|
|
28
|
-
>
|
|
29
|
-
<span
|
|
30
|
-
className={`shrink-0 text-[10px] uppercase tracking-wider w-12 ${typeColor(
|
|
31
|
-
msg.type,
|
|
32
|
-
)}`}
|
|
33
|
-
>
|
|
34
|
-
{msg.type}
|
|
35
|
-
</span>
|
|
36
|
-
<span className="flex-1 whitespace-pre-wrap break-words text-slate-700">
|
|
37
|
-
{(Array.isArray(msg.value) ? msg.value : [msg.value]).map(
|
|
38
|
-
(arg, idx) => (
|
|
39
|
-
<span key={idx}>
|
|
40
|
-
{idx > 0 ? " " : ""}
|
|
41
|
-
{formatValue(arg)}
|
|
42
|
-
</span>
|
|
43
|
-
),
|
|
44
|
-
)}
|
|
45
|
-
</span>
|
|
46
|
-
</div>
|
|
47
|
-
))}
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function typeColor(type: IConsoleMessage["type"]): string {
|
|
53
|
-
switch (type) {
|
|
54
|
-
case "error":
|
|
55
|
-
return "text-red-600";
|
|
56
|
-
case "warn":
|
|
57
|
-
return "text-amber-600";
|
|
58
|
-
case "info":
|
|
59
|
-
return "text-sky-700";
|
|
60
|
-
case "debug":
|
|
61
|
-
return "text-fuchsia-700";
|
|
62
|
-
case "dir":
|
|
63
|
-
case "table":
|
|
64
|
-
return "text-cyan-700";
|
|
65
|
-
default:
|
|
66
|
-
return "text-emerald-700";
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function formatValue(value: unknown, depth = 0): JSX.Element {
|
|
71
|
-
if (typeof value === "string")
|
|
72
|
-
return <span className="text-amber-700">{JSON.stringify(value)}</span>;
|
|
73
|
-
if (typeof value === "number")
|
|
74
|
-
return <span className="text-purple-700">{String(value)}</span>;
|
|
75
|
-
if (typeof value === "boolean")
|
|
76
|
-
return <span className="text-sky-700">{String(value)}</span>;
|
|
77
|
-
if (value === null) return <span className="text-slate-500">null</span>;
|
|
78
|
-
if (value === undefined)
|
|
79
|
-
return <span className="text-slate-500">undefined</span>;
|
|
80
|
-
if (typeof value === "function")
|
|
81
|
-
return <span className="text-slate-500">[Function]</span>;
|
|
82
|
-
if (Array.isArray(value))
|
|
83
|
-
return (
|
|
84
|
-
<span>
|
|
85
|
-
[
|
|
86
|
-
{value.map((item, idx) => (
|
|
87
|
-
<span key={idx}>
|
|
88
|
-
{idx > 0 ? ", " : ""}
|
|
89
|
-
{formatValue(item, depth + 1)}
|
|
90
|
-
</span>
|
|
91
|
-
))}
|
|
92
|
-
]
|
|
93
|
-
</span>
|
|
94
|
-
);
|
|
95
|
-
if (value instanceof Error)
|
|
96
|
-
return (
|
|
97
|
-
<span className="text-red-700">
|
|
98
|
-
{value.name}: {value.message}
|
|
99
|
-
</span>
|
|
100
|
-
);
|
|
101
|
-
try {
|
|
102
|
-
const entries = Object.entries(value as Record<string, unknown>);
|
|
103
|
-
if (entries.length === 0) return <span>{"{}"}</span>;
|
|
104
|
-
if (depth > 4) return <span className="text-slate-500">[...]</span>;
|
|
105
|
-
return (
|
|
106
|
-
<span>
|
|
107
|
-
{"{"}
|
|
108
|
-
{entries.map(([k, v], idx) => (
|
|
109
|
-
<span key={k}>
|
|
110
|
-
{idx > 0 ? ", " : " "}
|
|
111
|
-
<span className="text-[#3178c6]">{k}</span>:{" "}
|
|
112
|
-
{formatValue(v, depth + 1)}
|
|
113
|
-
</span>
|
|
114
|
-
))}
|
|
115
|
-
{" }"}
|
|
116
|
-
</span>
|
|
117
|
-
);
|
|
118
|
-
} catch {
|
|
119
|
-
return <span>{String(value)}</span>;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { JSX } from "react";
|
|
4
|
+
|
|
5
|
+
import type { IConsoleMessage } from "../structures/IConsoleMessage";
|
|
6
|
+
|
|
7
|
+
interface ConsoleViewerProps {
|
|
8
|
+
messages: IConsoleMessage[];
|
|
9
|
+
empty?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ConsoleViewer({
|
|
13
|
+
messages,
|
|
14
|
+
empty = "No output yet. Click Execute to run the compiled JavaScript.",
|
|
15
|
+
}: ConsoleViewerProps) {
|
|
16
|
+
if (messages.length === 0)
|
|
17
|
+
return (
|
|
18
|
+
<div className="flex h-full w-full items-center justify-center px-4 text-center font-mono text-[11px] text-slate-400">
|
|
19
|
+
{empty}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
return (
|
|
23
|
+
<div className="h-full w-full overflow-auto p-3 font-mono text-[12px] leading-snug">
|
|
24
|
+
{messages.map((msg, i) => (
|
|
25
|
+
<div
|
|
26
|
+
key={i}
|
|
27
|
+
className="flex gap-2 border-b border-[#d8e7f4] py-1 last:border-b-0"
|
|
28
|
+
>
|
|
29
|
+
<span
|
|
30
|
+
className={`shrink-0 text-[10px] uppercase tracking-wider w-12 ${typeColor(
|
|
31
|
+
msg.type,
|
|
32
|
+
)}`}
|
|
33
|
+
>
|
|
34
|
+
{msg.type}
|
|
35
|
+
</span>
|
|
36
|
+
<span className="flex-1 whitespace-pre-wrap break-words text-slate-700">
|
|
37
|
+
{(Array.isArray(msg.value) ? msg.value : [msg.value]).map(
|
|
38
|
+
(arg, idx) => (
|
|
39
|
+
<span key={idx}>
|
|
40
|
+
{idx > 0 ? " " : ""}
|
|
41
|
+
{formatValue(arg)}
|
|
42
|
+
</span>
|
|
43
|
+
),
|
|
44
|
+
)}
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
))}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function typeColor(type: IConsoleMessage["type"]): string {
|
|
53
|
+
switch (type) {
|
|
54
|
+
case "error":
|
|
55
|
+
return "text-red-600";
|
|
56
|
+
case "warn":
|
|
57
|
+
return "text-amber-600";
|
|
58
|
+
case "info":
|
|
59
|
+
return "text-sky-700";
|
|
60
|
+
case "debug":
|
|
61
|
+
return "text-fuchsia-700";
|
|
62
|
+
case "dir":
|
|
63
|
+
case "table":
|
|
64
|
+
return "text-cyan-700";
|
|
65
|
+
default:
|
|
66
|
+
return "text-emerald-700";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function formatValue(value: unknown, depth = 0): JSX.Element {
|
|
71
|
+
if (typeof value === "string")
|
|
72
|
+
return <span className="text-amber-700">{JSON.stringify(value)}</span>;
|
|
73
|
+
if (typeof value === "number")
|
|
74
|
+
return <span className="text-purple-700">{String(value)}</span>;
|
|
75
|
+
if (typeof value === "boolean")
|
|
76
|
+
return <span className="text-sky-700">{String(value)}</span>;
|
|
77
|
+
if (value === null) return <span className="text-slate-500">null</span>;
|
|
78
|
+
if (value === undefined)
|
|
79
|
+
return <span className="text-slate-500">undefined</span>;
|
|
80
|
+
if (typeof value === "function")
|
|
81
|
+
return <span className="text-slate-500">[Function]</span>;
|
|
82
|
+
if (Array.isArray(value))
|
|
83
|
+
return (
|
|
84
|
+
<span>
|
|
85
|
+
[
|
|
86
|
+
{value.map((item, idx) => (
|
|
87
|
+
<span key={idx}>
|
|
88
|
+
{idx > 0 ? ", " : ""}
|
|
89
|
+
{formatValue(item, depth + 1)}
|
|
90
|
+
</span>
|
|
91
|
+
))}
|
|
92
|
+
]
|
|
93
|
+
</span>
|
|
94
|
+
);
|
|
95
|
+
if (value instanceof Error)
|
|
96
|
+
return (
|
|
97
|
+
<span className="text-red-700">
|
|
98
|
+
{value.name}: {value.message}
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
try {
|
|
102
|
+
const entries = Object.entries(value as Record<string, unknown>);
|
|
103
|
+
if (entries.length === 0) return <span>{"{}"}</span>;
|
|
104
|
+
if (depth > 4) return <span className="text-slate-500">[...]</span>;
|
|
105
|
+
return (
|
|
106
|
+
<span>
|
|
107
|
+
{"{"}
|
|
108
|
+
{entries.map(([k, v], idx) => (
|
|
109
|
+
<span key={k}>
|
|
110
|
+
{idx > 0 ? ", " : " "}
|
|
111
|
+
<span className="text-[#3178c6]">{k}</span>:{" "}
|
|
112
|
+
{formatValue(v, depth + 1)}
|
|
113
|
+
</span>
|
|
114
|
+
))}
|
|
115
|
+
{" }"}
|
|
116
|
+
</span>
|
|
117
|
+
);
|
|
118
|
+
} catch {
|
|
119
|
+
return <span>{String(value)}</span>;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { IPlaygroundDependencyProgress } from "../structures/IPlaygroundDependencyProgress";
|
|
4
|
-
|
|
5
|
-
interface DependencyProgressModalProps {
|
|
6
|
-
progress: IPlaygroundDependencyProgress | null;
|
|
7
|
-
packages: readonly string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function DependencyProgressModal({
|
|
11
|
-
progress,
|
|
12
|
-
packages,
|
|
13
|
-
}: DependencyProgressModalProps) {
|
|
14
|
-
if (!progress) return null;
|
|
15
|
-
const total = Math.max(progress.total, 1);
|
|
16
|
-
const ratio = Math.min(1, Math.max(0, progress.completed / total));
|
|
17
|
-
const activePackage =
|
|
18
|
-
progress.packageName && progress.version
|
|
19
|
-
? `${progress.packageName}@${progress.version}`
|
|
20
|
-
: progress.packageName;
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-[#102a43]/35 px-4 backdrop-blur-sm">
|
|
24
|
-
<div className="w-full max-w-md rounded-2xl border border-[#b9d5ee] bg-white p-5 shadow-[0_28px_70px_rgba(35,90,151,0.25)]">
|
|
25
|
-
<div className="flex items-start justify-between gap-4">
|
|
26
|
-
<div>
|
|
27
|
-
<div className="font-mono text-[11px] uppercase text-[#3178c6]">
|
|
28
|
-
Dependencies
|
|
29
|
-
</div>
|
|
30
|
-
<h2 className="mt-1 font-mono text-base text-[#102a43]">
|
|
31
|
-
Installing npm packages
|
|
32
|
-
</h2>
|
|
33
|
-
</div>
|
|
34
|
-
<div className="font-mono text-[11px] text-slate-500">
|
|
35
|
-
{progress.completed}/{total}
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div className="mt-4 h-2 overflow-hidden rounded-full bg-[#e7f0f8]">
|
|
40
|
-
<div
|
|
41
|
-
className="h-full bg-[#3178c6] transition-[width]"
|
|
42
|
-
style={{ width: `${Math.max(8, ratio * 100)}%` }}
|
|
43
|
-
/>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div className="mt-4 space-y-1 font-mono">
|
|
47
|
-
{activePackage && (
|
|
48
|
-
<div className="text-[12px] text-slate-700">{activePackage}</div>
|
|
49
|
-
)}
|
|
50
|
-
<div className="text-[11px] text-slate-500">{progress.message}</div>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
{packages.length > 0 && (
|
|
54
|
-
<div className="mt-4 flex flex-wrap gap-1.5">
|
|
55
|
-
{packages.slice(0, 8).map((name) => (
|
|
56
|
-
<span
|
|
57
|
-
key={name}
|
|
58
|
-
className="rounded border border-[#d2e4f4] bg-[#f7fbff] px-2 py-1 font-mono text-[10px] text-slate-600"
|
|
59
|
-
>
|
|
60
|
-
{name}
|
|
61
|
-
</span>
|
|
62
|
-
))}
|
|
63
|
-
{packages.length > 8 && (
|
|
64
|
-
<span className="rounded border border-[#d2e4f4] bg-[#f7fbff] px-2 py-1 font-mono text-[10px] text-slate-500">
|
|
65
|
-
+{packages.length - 8}
|
|
66
|
-
</span>
|
|
67
|
-
)}
|
|
68
|
-
</div>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { IPlaygroundDependencyProgress } from "../structures/IPlaygroundDependencyProgress";
|
|
4
|
+
|
|
5
|
+
interface DependencyProgressModalProps {
|
|
6
|
+
progress: IPlaygroundDependencyProgress | null;
|
|
7
|
+
packages: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function DependencyProgressModal({
|
|
11
|
+
progress,
|
|
12
|
+
packages,
|
|
13
|
+
}: DependencyProgressModalProps) {
|
|
14
|
+
if (!progress) return null;
|
|
15
|
+
const total = Math.max(progress.total, 1);
|
|
16
|
+
const ratio = Math.min(1, Math.max(0, progress.completed / total));
|
|
17
|
+
const activePackage =
|
|
18
|
+
progress.packageName && progress.version
|
|
19
|
+
? `${progress.packageName}@${progress.version}`
|
|
20
|
+
: progress.packageName;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-[#102a43]/35 px-4 backdrop-blur-sm">
|
|
24
|
+
<div className="w-full max-w-md rounded-2xl border border-[#b9d5ee] bg-white p-5 shadow-[0_28px_70px_rgba(35,90,151,0.25)]">
|
|
25
|
+
<div className="flex items-start justify-between gap-4">
|
|
26
|
+
<div>
|
|
27
|
+
<div className="font-mono text-[11px] uppercase text-[#3178c6]">
|
|
28
|
+
Dependencies
|
|
29
|
+
</div>
|
|
30
|
+
<h2 className="mt-1 font-mono text-base text-[#102a43]">
|
|
31
|
+
Installing npm packages
|
|
32
|
+
</h2>
|
|
33
|
+
</div>
|
|
34
|
+
<div className="font-mono text-[11px] text-slate-500">
|
|
35
|
+
{progress.completed}/{total}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div className="mt-4 h-2 overflow-hidden rounded-full bg-[#e7f0f8]">
|
|
40
|
+
<div
|
|
41
|
+
className="h-full bg-[#3178c6] transition-[width]"
|
|
42
|
+
style={{ width: `${Math.max(8, ratio * 100)}%` }}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div className="mt-4 space-y-1 font-mono">
|
|
47
|
+
{activePackage && (
|
|
48
|
+
<div className="text-[12px] text-slate-700">{activePackage}</div>
|
|
49
|
+
)}
|
|
50
|
+
<div className="text-[11px] text-slate-500">{progress.message}</div>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
{packages.length > 0 && (
|
|
54
|
+
<div className="mt-4 flex flex-wrap gap-1.5">
|
|
55
|
+
{packages.slice(0, 8).map((name) => (
|
|
56
|
+
<span
|
|
57
|
+
key={name}
|
|
58
|
+
className="rounded border border-[#d2e4f4] bg-[#f7fbff] px-2 py-1 font-mono text-[10px] text-slate-600"
|
|
59
|
+
>
|
|
60
|
+
{name}
|
|
61
|
+
</span>
|
|
62
|
+
))}
|
|
63
|
+
{packages.length > 8 && (
|
|
64
|
+
<span className="rounded border border-[#d2e4f4] bg-[#f7fbff] px-2 py-1 font-mono text-[10px] text-slate-500">
|
|
65
|
+
+{packages.length - 8}
|
|
66
|
+
</span>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
|
|
5
|
-
import type { ICompilerService } from "../structures/ICompilerService";
|
|
6
|
-
|
|
7
|
-
export function DiagnosticsPanel({
|
|
8
|
-
diagnostics,
|
|
9
|
-
}: {
|
|
10
|
-
diagnostics: ICompilerService.IDiagnostic[];
|
|
11
|
-
}) {
|
|
12
|
-
const [expanded, setExpanded] = useState(false);
|
|
13
|
-
const errorCount = diagnostics.filter((d) => d.severity === "error").length;
|
|
14
|
-
const warnCount = diagnostics.filter((d) => d.severity === "warning").length;
|
|
15
|
-
|
|
16
|
-
if (diagnostics.length === 0)
|
|
17
|
-
return (
|
|
18
|
-
<div className="flex shrink-0 items-center gap-3 border-t border-[#c7dff4] bg-[#eef6ff] px-4 py-2">
|
|
19
|
-
<span className="text-emerald-400 text-xs">●</span>
|
|
20
|
-
<span className="font-mono text-[12px] text-slate-600">
|
|
21
|
-
0 errors · 0 warnings
|
|
22
|
-
</span>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div className="shrink-0 border-t border-[#c7dff4] bg-[#eef6ff]">
|
|
28
|
-
<button
|
|
29
|
-
onClick={() => setExpanded((v) => !v)}
|
|
30
|
-
className="flex w-full items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-[#e1effc]"
|
|
31
|
-
>
|
|
32
|
-
<span
|
|
33
|
-
className={`text-xs ${
|
|
34
|
-
errorCount > 0 ? "text-red-400" : "text-yellow-400"
|
|
35
|
-
}`}
|
|
36
|
-
>
|
|
37
|
-
●
|
|
38
|
-
</span>
|
|
39
|
-
<span className="font-mono text-[12px] text-slate-700">
|
|
40
|
-
{errorCount} error{errorCount === 1 ? "" : "s"} · {warnCount} warning
|
|
41
|
-
{warnCount === 1 ? "" : "s"}
|
|
42
|
-
</span>
|
|
43
|
-
<span className="ml-auto font-mono text-[10px] text-slate-400">
|
|
44
|
-
{expanded ? "▲ collapse" : "▼ expand"}
|
|
45
|
-
</span>
|
|
46
|
-
</button>
|
|
47
|
-
{expanded && (
|
|
48
|
-
<div className="max-h-48 overflow-auto border-t border-[#c7dff4]">
|
|
49
|
-
{diagnostics.map((d, i) => (
|
|
50
|
-
<div
|
|
51
|
-
key={i}
|
|
52
|
-
className="flex gap-3 border-b border-[#d8e7f4] px-4 py-2 font-mono text-[12px] last:border-b-0"
|
|
53
|
-
>
|
|
54
|
-
<span
|
|
55
|
-
className={`shrink-0 ${
|
|
56
|
-
d.severity === "error" ? "text-red-400" : "text-yellow-400"
|
|
57
|
-
}`}
|
|
58
|
-
>
|
|
59
|
-
{d.severity === "error" ? "✗" : "!"}
|
|
60
|
-
</span>
|
|
61
|
-
<span className="w-16 shrink-0 text-slate-500">
|
|
62
|
-
{d.line}:{d.column}
|
|
63
|
-
</span>
|
|
64
|
-
<span className="w-16 shrink-0 text-slate-400">
|
|
65
|
-
{d.code ?? ""}
|
|
66
|
-
</span>
|
|
67
|
-
<span className="text-slate-700">{d.message}</span>
|
|
68
|
-
</div>
|
|
69
|
-
))}
|
|
70
|
-
</div>
|
|
71
|
-
)}
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
import type { ICompilerService } from "../structures/ICompilerService";
|
|
6
|
+
|
|
7
|
+
export function DiagnosticsPanel({
|
|
8
|
+
diagnostics,
|
|
9
|
+
}: {
|
|
10
|
+
diagnostics: ICompilerService.IDiagnostic[];
|
|
11
|
+
}) {
|
|
12
|
+
const [expanded, setExpanded] = useState(false);
|
|
13
|
+
const errorCount = diagnostics.filter((d) => d.severity === "error").length;
|
|
14
|
+
const warnCount = diagnostics.filter((d) => d.severity === "warning").length;
|
|
15
|
+
|
|
16
|
+
if (diagnostics.length === 0)
|
|
17
|
+
return (
|
|
18
|
+
<div className="flex shrink-0 items-center gap-3 border-t border-[#c7dff4] bg-[#eef6ff] px-4 py-2">
|
|
19
|
+
<span className="text-emerald-400 text-xs">●</span>
|
|
20
|
+
<span className="font-mono text-[12px] text-slate-600">
|
|
21
|
+
0 errors · 0 warnings
|
|
22
|
+
</span>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="shrink-0 border-t border-[#c7dff4] bg-[#eef6ff]">
|
|
28
|
+
<button
|
|
29
|
+
onClick={() => setExpanded((v) => !v)}
|
|
30
|
+
className="flex w-full items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-[#e1effc]"
|
|
31
|
+
>
|
|
32
|
+
<span
|
|
33
|
+
className={`text-xs ${
|
|
34
|
+
errorCount > 0 ? "text-red-400" : "text-yellow-400"
|
|
35
|
+
}`}
|
|
36
|
+
>
|
|
37
|
+
●
|
|
38
|
+
</span>
|
|
39
|
+
<span className="font-mono text-[12px] text-slate-700">
|
|
40
|
+
{errorCount} error{errorCount === 1 ? "" : "s"} · {warnCount} warning
|
|
41
|
+
{warnCount === 1 ? "" : "s"}
|
|
42
|
+
</span>
|
|
43
|
+
<span className="ml-auto font-mono text-[10px] text-slate-400">
|
|
44
|
+
{expanded ? "▲ collapse" : "▼ expand"}
|
|
45
|
+
</span>
|
|
46
|
+
</button>
|
|
47
|
+
{expanded && (
|
|
48
|
+
<div className="max-h-48 overflow-auto border-t border-[#c7dff4]">
|
|
49
|
+
{diagnostics.map((d, i) => (
|
|
50
|
+
<div
|
|
51
|
+
key={i}
|
|
52
|
+
className="flex gap-3 border-b border-[#d8e7f4] px-4 py-2 font-mono text-[12px] last:border-b-0"
|
|
53
|
+
>
|
|
54
|
+
<span
|
|
55
|
+
className={`shrink-0 ${
|
|
56
|
+
d.severity === "error" ? "text-red-400" : "text-yellow-400"
|
|
57
|
+
}`}
|
|
58
|
+
>
|
|
59
|
+
{d.severity === "error" ? "✗" : "!"}
|
|
60
|
+
</span>
|
|
61
|
+
<span className="w-16 shrink-0 text-slate-500">
|
|
62
|
+
{d.line}:{d.column}
|
|
63
|
+
</span>
|
|
64
|
+
<span className="w-16 shrink-0 text-slate-400">
|
|
65
|
+
{d.code ?? ""}
|
|
66
|
+
</span>
|
|
67
|
+
<span className="text-slate-700">{d.message}</span>
|
|
68
|
+
</div>
|
|
69
|
+
))}
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|