@kohryan/moodui 0.0.14 → 0.0.15
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/cli.mjs +25 -1
- package/dist/ui/assets/index-ViFb9uE_.js +58 -0
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/src/ui/main.tsx +310 -7
- package/dist/ui/assets/index-CMk6XQXy.js +0 -58
package/dist/cli.mjs
CHANGED
|
@@ -1164,8 +1164,32 @@ async function runUI() {
|
|
|
1164
1164
|
uiDir = path2.join(__dirname2, "..", "dist", "ui");
|
|
1165
1165
|
}
|
|
1166
1166
|
const PORT = 3e3;
|
|
1167
|
-
|
|
1167
|
+
const workingDir = process.cwd();
|
|
1168
|
+
console.log(`Starting MoodUI UI at http://localhost:${PORT}`);
|
|
1169
|
+
console.log(`Working directory: ${workingDir}`);
|
|
1168
1170
|
const server = http.createServer(async (req, res) => {
|
|
1171
|
+
if (req.method === "POST" && req.url === "/api/save-file") {
|
|
1172
|
+
try {
|
|
1173
|
+
let body = "";
|
|
1174
|
+
for await (const chunk of req) {
|
|
1175
|
+
body += chunk.toString();
|
|
1176
|
+
}
|
|
1177
|
+
const { path: filePath2, code } = JSON.parse(body);
|
|
1178
|
+
const resolvedOut = path2.resolve(workingDir, filePath2);
|
|
1179
|
+
await fs6.mkdir(path2.dirname(resolvedOut), { recursive: true });
|
|
1180
|
+
await fs6.writeFile(resolvedOut, code, "utf8");
|
|
1181
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1182
|
+
res.end(JSON.stringify({ success: true, path: resolvedOut }));
|
|
1183
|
+
console.log(`OK: wrote ${resolvedOut}`);
|
|
1184
|
+
return;
|
|
1185
|
+
} catch (err) {
|
|
1186
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
1187
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
1188
|
+
res.end(JSON.stringify({ success: false, error: errorMsg }));
|
|
1189
|
+
console.error(`Error saving file: ${errorMsg}`);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1169
1193
|
let filePath = path2.join(uiDir, req.url === "/" ? "index.html" : req.url);
|
|
1170
1194
|
const extname = String(path2.extname(filePath)).toLowerCase();
|
|
1171
1195
|
const mimeTypes = {
|