@gallop.software/studio 2.3.157 → 2.3.159
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/client/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
12
12
|
}
|
|
13
13
|
</style>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-DTMba9ep.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-DfPQBmNf.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
package/dist/server/index.js
CHANGED
|
@@ -4835,6 +4835,92 @@ async function handleFontsRename(request) {
|
|
|
4835
4835
|
return jsonResponse({ error: "Failed to rename" }, { status: 500 });
|
|
4836
4836
|
}
|
|
4837
4837
|
}
|
|
4838
|
+
async function handleFontsRenameStream(request) {
|
|
4839
|
+
try {
|
|
4840
|
+
const { oldPath, newName } = await request.json();
|
|
4841
|
+
if (!oldPath || !newName) {
|
|
4842
|
+
return jsonResponse({ error: "oldPath and newName are required" }, { status: 400 });
|
|
4843
|
+
}
|
|
4844
|
+
if (!oldPath.startsWith("_fonts/")) {
|
|
4845
|
+
return jsonResponse({ error: "Can only rename items in _fonts/" }, { status: 400 });
|
|
4846
|
+
}
|
|
4847
|
+
if (newName.includes("/") || newName.includes("\\")) {
|
|
4848
|
+
return jsonResponse({ error: "Invalid folder name" }, { status: 400 });
|
|
4849
|
+
}
|
|
4850
|
+
const oldFullPath = getWorkspacePath(oldPath);
|
|
4851
|
+
const parentDir = path11.dirname(oldPath);
|
|
4852
|
+
const oldFolderName = path11.basename(oldPath).toLowerCase();
|
|
4853
|
+
const newFolderName = newName.toLowerCase();
|
|
4854
|
+
const newPath = `${parentDir}/${newFolderName}`;
|
|
4855
|
+
const newFullPath = getWorkspacePath(newPath);
|
|
4856
|
+
let isDirectory = false;
|
|
4857
|
+
try {
|
|
4858
|
+
const stat = await fs12.stat(oldFullPath);
|
|
4859
|
+
isDirectory = stat.isDirectory();
|
|
4860
|
+
} catch {
|
|
4861
|
+
return jsonResponse({ error: "Path not found" }, { status: 404 });
|
|
4862
|
+
}
|
|
4863
|
+
try {
|
|
4864
|
+
await fs12.stat(newFullPath);
|
|
4865
|
+
return jsonResponse({ error: "A folder with that name already exists" }, { status: 400 });
|
|
4866
|
+
} catch {
|
|
4867
|
+
}
|
|
4868
|
+
const encoder = new TextEncoder();
|
|
4869
|
+
const stream = new ReadableStream({
|
|
4870
|
+
async start(controller) {
|
|
4871
|
+
const send = (data) => {
|
|
4872
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}
|
|
4873
|
+
|
|
4874
|
+
`));
|
|
4875
|
+
};
|
|
4876
|
+
try {
|
|
4877
|
+
send({ status: "progress", message: `Renaming folder to ${newFolderName}...`, current: 0, total: 1 });
|
|
4878
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
4879
|
+
await fs12.rename(oldFullPath, newFullPath);
|
|
4880
|
+
if (isDirectory) {
|
|
4881
|
+
const entries = await fs12.readdir(newFullPath);
|
|
4882
|
+
const filesToRename = entries.filter((entry) => {
|
|
4883
|
+
const entryLower = entry.toLowerCase();
|
|
4884
|
+
return entryLower.startsWith(oldFolderName + "-") || entryLower.startsWith(oldFolderName + "_");
|
|
4885
|
+
});
|
|
4886
|
+
let renamed = 0;
|
|
4887
|
+
for (const entry of filesToRename) {
|
|
4888
|
+
const entryLower = entry.toLowerCase();
|
|
4889
|
+
const separator = entryLower.startsWith(oldFolderName + "-") ? "-" : "_";
|
|
4890
|
+
const suffix = entry.substring(oldFolderName.length);
|
|
4891
|
+
const newFileName = newFolderName + suffix.toLowerCase();
|
|
4892
|
+
send({ status: "progress", message: `Renaming ${entry} \u2192 ${newFileName}...`, current: renamed + 1, total: filesToRename.length });
|
|
4893
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
4894
|
+
const oldFilePath = path11.join(newFullPath, entry);
|
|
4895
|
+
const newFilePath = path11.join(newFullPath, newFileName);
|
|
4896
|
+
await fs12.rename(oldFilePath, newFilePath);
|
|
4897
|
+
renamed++;
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4900
|
+
send({
|
|
4901
|
+
status: "complete",
|
|
4902
|
+
message: `Renamed to ${newFolderName}`,
|
|
4903
|
+
oldPath,
|
|
4904
|
+
newPath
|
|
4905
|
+
});
|
|
4906
|
+
} catch (err) {
|
|
4907
|
+
send({ status: "error", message: String(err) });
|
|
4908
|
+
}
|
|
4909
|
+
controller.close();
|
|
4910
|
+
}
|
|
4911
|
+
});
|
|
4912
|
+
return new Response(stream, {
|
|
4913
|
+
headers: {
|
|
4914
|
+
"Content-Type": "text/event-stream",
|
|
4915
|
+
"Cache-Control": "no-cache",
|
|
4916
|
+
"Connection": "keep-alive"
|
|
4917
|
+
}
|
|
4918
|
+
});
|
|
4919
|
+
} catch (error) {
|
|
4920
|
+
console.error("Error renaming:", error);
|
|
4921
|
+
return jsonResponse({ error: "Failed to rename" }, { status: 500 });
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4838
4924
|
async function handleFontsScan(request) {
|
|
4839
4925
|
try {
|
|
4840
4926
|
const { folder } = await request.json();
|
|
@@ -4988,6 +5074,7 @@ async function handleFontsAssign(request) {
|
|
|
4988
5074
|
const baseName = path11.basename(ttfFile, ".ttf");
|
|
4989
5075
|
const woff2Name = baseName + ".woff2";
|
|
4990
5076
|
send({ status: "progress", message: `Compressing ${ttfFile}...`, current: i + 1, total: ttfFiles.length, currentFile: ttfFile });
|
|
5077
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
4991
5078
|
try {
|
|
4992
5079
|
const ttfPath = path11.join(folderPath, ttfFile);
|
|
4993
5080
|
const input = readFileSync(ttfPath);
|
|
@@ -5022,6 +5109,7 @@ async function handleFontsAssign(request) {
|
|
|
5022
5109
|
for (let i = 0; i < assignments.length; i++) {
|
|
5023
5110
|
const assignmentName = assignments[i];
|
|
5024
5111
|
send({ status: "progress", message: `Writing ${assignmentName}.ts...`, current: i + 1, total: assignments.length });
|
|
5112
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
5025
5113
|
try {
|
|
5026
5114
|
const fileName = `${assignmentName}.ts`;
|
|
5027
5115
|
const filePath = path11.join(srcFontsPath, fileName);
|
|
@@ -5145,6 +5233,7 @@ async function startServer(options) {
|
|
|
5145
5233
|
app.post("/api/studio/fonts/create-folder", wrapHandler(handleFontsCreateFolder));
|
|
5146
5234
|
app.post("/api/studio/fonts/delete", wrapHandler(handleFontsDelete));
|
|
5147
5235
|
app.post("/api/studio/fonts/rename", wrapHandler(handleFontsRename));
|
|
5236
|
+
app.post("/api/studio/fonts/rename-stream", wrapHandler(handleFontsRenameStream, true));
|
|
5148
5237
|
app.post("/api/studio/fonts/scan", wrapHandler(handleFontsScan));
|
|
5149
5238
|
app.get("/api/studio/fonts/assignments", wrapHandler(handleFontsListAssignments));
|
|
5150
5239
|
app.post("/api/studio/fonts/assign-stream", wrapHandler(handleFontsAssign, true));
|