@gallop.software/studio 2.3.167 → 2.3.169
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/README.md +61 -3
- package/dist/client/assets/index-CVJQOX08.js +139 -0
- package/dist/client/assets/index-Cs_5fxll.js +139 -0
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +68 -48
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
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-CVJQOX08.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
|
@@ -5042,7 +5042,6 @@ async function handleFontsRenameStream(request) {
|
|
|
5042
5042
|
};
|
|
5043
5043
|
try {
|
|
5044
5044
|
send({ status: "progress", message: `Renaming folder to ${newFolderName}...`, current: 0, total: 1 });
|
|
5045
|
-
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
5046
5045
|
await fs12.rename(oldFullPath, newFullPath);
|
|
5047
5046
|
if (isDirectory) {
|
|
5048
5047
|
const entries = await fs12.readdir(newFullPath);
|
|
@@ -5057,7 +5056,6 @@ async function handleFontsRenameStream(request) {
|
|
|
5057
5056
|
const suffix = entry.substring(oldFolderName.length);
|
|
5058
5057
|
const newFileName = newFolderName + suffix.toLowerCase();
|
|
5059
5058
|
send({ status: "progress", message: `Renaming ${entry} \u2192 ${newFileName}...`, current: renamed + 1, total: filesToRename.length });
|
|
5060
|
-
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
5061
5059
|
const oldFilePath = path11.join(newFullPath, entry);
|
|
5062
5060
|
const newFilePath = path11.join(newFullPath, newFileName);
|
|
5063
5061
|
await fs12.rename(oldFilePath, newFilePath);
|
|
@@ -5201,9 +5199,11 @@ async function handleFontsDeleteAssignment(request) {
|
|
|
5201
5199
|
}
|
|
5202
5200
|
async function handleFontsAssign(request) {
|
|
5203
5201
|
try {
|
|
5204
|
-
const { folder, assignments } = await request.json();
|
|
5205
|
-
|
|
5206
|
-
|
|
5202
|
+
const { folder, files, assignments } = await request.json();
|
|
5203
|
+
const isFileMode = files && Array.isArray(files) && files.length > 0;
|
|
5204
|
+
const isFolderMode = folder && folder.startsWith("_fonts/");
|
|
5205
|
+
if (!isFileMode && !isFolderMode) {
|
|
5206
|
+
return jsonResponse({ error: "Either folder or files must be provided" }, { status: 400 });
|
|
5207
5207
|
}
|
|
5208
5208
|
if (!assignments || !Array.isArray(assignments) || assignments.length === 0) {
|
|
5209
5209
|
return jsonResponse({ error: "At least one assignment is required" }, { status: 400 });
|
|
@@ -5213,8 +5213,13 @@ async function handleFontsAssign(request) {
|
|
|
5213
5213
|
return jsonResponse({ error: `Invalid assignment name: ${name}` }, { status: 400 });
|
|
5214
5214
|
}
|
|
5215
5215
|
}
|
|
5216
|
-
|
|
5217
|
-
|
|
5216
|
+
if (isFileMode) {
|
|
5217
|
+
for (const filePath of files) {
|
|
5218
|
+
if (!filePath.startsWith("_fonts/") || !filePath.toLowerCase().endsWith(".woff2")) {
|
|
5219
|
+
return jsonResponse({ error: `Invalid file path: ${filePath}. Must be a woff2 file in _fonts/` }, { status: 400 });
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5218
5223
|
const encoder = new TextEncoder();
|
|
5219
5224
|
const stream = new ReadableStream({
|
|
5220
5225
|
async start(controller) {
|
|
@@ -5224,49 +5229,65 @@ async function handleFontsAssign(request) {
|
|
|
5224
5229
|
`));
|
|
5225
5230
|
};
|
|
5226
5231
|
try {
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5232
|
+
let fontMap;
|
|
5233
|
+
if (isFileMode) {
|
|
5234
|
+
send({ status: "progress", message: `Processing ${files.length} selected file${files.length > 1 ? "s" : ""}...`, current: 0, total: files.length });
|
|
5235
|
+
fontMap = files.map((filePath) => {
|
|
5236
|
+
const relativePath = filePath.replace(/^_fonts\//, "");
|
|
5237
|
+
const baseName = path11.basename(filePath, ".woff2");
|
|
5238
|
+
const { weight, style } = parseFontMetadata(baseName);
|
|
5239
|
+
return {
|
|
5240
|
+
path: relativePath,
|
|
5241
|
+
weight,
|
|
5242
|
+
style
|
|
5243
|
+
};
|
|
5244
|
+
});
|
|
5245
|
+
} else {
|
|
5246
|
+
const folderPath = getWorkspacePath(folder);
|
|
5247
|
+
const folderName = path11.basename(folder);
|
|
5248
|
+
const entries = await fs12.readdir(folderPath);
|
|
5249
|
+
const ttfFiles = entries.filter((f) => f.toLowerCase().endsWith(".ttf"));
|
|
5250
|
+
let woff2Files = entries.filter((f) => f.toLowerCase().endsWith(".woff2"));
|
|
5251
|
+
if (ttfFiles.length === 0 && woff2Files.length === 0) {
|
|
5252
|
+
send({ status: "error", message: "No font files found in folder" });
|
|
5253
|
+
controller.close();
|
|
5254
|
+
return;
|
|
5255
|
+
}
|
|
5256
|
+
if (woff2Files.length === 0 && ttfFiles.length > 0) {
|
|
5257
|
+
send({ status: "progress", message: "Generating woff2 files...", current: 0, total: ttfFiles.length });
|
|
5258
|
+
const ttf2woff2Module = await import("ttf2woff2");
|
|
5259
|
+
const ttf2woff2 = ttf2woff2Module.default;
|
|
5260
|
+
for (let i = 0; i < ttfFiles.length; i++) {
|
|
5261
|
+
const ttfFile = ttfFiles[i];
|
|
5262
|
+
const baseName = path11.basename(ttfFile, ".ttf");
|
|
5263
|
+
const woff2Name = baseName + ".woff2";
|
|
5264
|
+
send({ status: "progress", message: `Compressing ${ttfFile}...`, current: i + 1, total: ttfFiles.length, currentFile: ttfFile });
|
|
5265
|
+
try {
|
|
5266
|
+
const ttfPath = path11.join(folderPath, ttfFile);
|
|
5267
|
+
const input = readFileSync(ttfPath);
|
|
5268
|
+
const woff2Data = ttf2woff2(input);
|
|
5269
|
+
writeFileSync(path11.join(folderPath, woff2Name), woff2Data);
|
|
5270
|
+
woff2Files.push(woff2Name);
|
|
5271
|
+
} catch (err) {
|
|
5272
|
+
send({ status: "progress", message: `Failed to compress ${ttfFile}`, error: String(err) });
|
|
5273
|
+
}
|
|
5253
5274
|
}
|
|
5254
5275
|
}
|
|
5276
|
+
if (woff2Files.length === 0) {
|
|
5277
|
+
send({ status: "error", message: "No woff2 files available" });
|
|
5278
|
+
controller.close();
|
|
5279
|
+
return;
|
|
5280
|
+
}
|
|
5281
|
+
fontMap = woff2Files.map((file) => {
|
|
5282
|
+
const baseName = path11.basename(file, ".woff2");
|
|
5283
|
+
const { weight, style } = parseFontMetadata(baseName);
|
|
5284
|
+
return {
|
|
5285
|
+
path: `${folderName}/${file}`,
|
|
5286
|
+
weight,
|
|
5287
|
+
style
|
|
5288
|
+
};
|
|
5289
|
+
});
|
|
5255
5290
|
}
|
|
5256
|
-
if (woff2Files.length === 0) {
|
|
5257
|
-
send({ status: "error", message: "No woff2 files available" });
|
|
5258
|
-
controller.close();
|
|
5259
|
-
return;
|
|
5260
|
-
}
|
|
5261
|
-
const fontMap = woff2Files.map((file) => {
|
|
5262
|
-
const baseName = path11.basename(file, ".woff2");
|
|
5263
|
-
const { weight, style } = parseFontMetadata(baseName);
|
|
5264
|
-
return {
|
|
5265
|
-
path: `${folderName}/${file}`,
|
|
5266
|
-
weight,
|
|
5267
|
-
style
|
|
5268
|
-
};
|
|
5269
|
-
});
|
|
5270
5291
|
const srcFontsPath = getWorkspacePath("src/fonts");
|
|
5271
5292
|
if (!existsSync(srcFontsPath)) {
|
|
5272
5293
|
mkdirSync(srcFontsPath, { recursive: true });
|
|
@@ -5276,7 +5297,6 @@ async function handleFontsAssign(request) {
|
|
|
5276
5297
|
for (let i = 0; i < assignments.length; i++) {
|
|
5277
5298
|
const assignmentName = assignments[i];
|
|
5278
5299
|
send({ status: "progress", message: `Writing ${assignmentName}.ts...`, current: i + 1, total: assignments.length });
|
|
5279
|
-
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
5280
5300
|
try {
|
|
5281
5301
|
const fileName = `${assignmentName}.ts`;
|
|
5282
5302
|
const filePath = path11.join(srcFontsPath, fileName);
|