@gallop.software/studio 2.3.168 → 2.3.170
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/assets/index-Of2c5V5i.js +139 -0
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +68 -44
- 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-Of2c5V5i.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
|
@@ -5199,9 +5199,11 @@ async function handleFontsDeleteAssignment(request) {
|
|
|
5199
5199
|
}
|
|
5200
5200
|
async function handleFontsAssign(request) {
|
|
5201
5201
|
try {
|
|
5202
|
-
const { folder, assignments } = await request.json();
|
|
5203
|
-
|
|
5204
|
-
|
|
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 });
|
|
5205
5207
|
}
|
|
5206
5208
|
if (!assignments || !Array.isArray(assignments) || assignments.length === 0) {
|
|
5207
5209
|
return jsonResponse({ error: "At least one assignment is required" }, { status: 400 });
|
|
@@ -5211,8 +5213,13 @@ async function handleFontsAssign(request) {
|
|
|
5211
5213
|
return jsonResponse({ error: `Invalid assignment name: ${name}` }, { status: 400 });
|
|
5212
5214
|
}
|
|
5213
5215
|
}
|
|
5214
|
-
|
|
5215
|
-
|
|
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
|
+
}
|
|
5216
5223
|
const encoder = new TextEncoder();
|
|
5217
5224
|
const stream = new ReadableStream({
|
|
5218
5225
|
async start(controller) {
|
|
@@ -5222,48 +5229,65 @@ async function handleFontsAssign(request) {
|
|
|
5222
5229
|
`));
|
|
5223
5230
|
};
|
|
5224
5231
|
try {
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
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
|
+
}
|
|
5250
5274
|
}
|
|
5251
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
|
+
});
|
|
5252
5290
|
}
|
|
5253
|
-
if (woff2Files.length === 0) {
|
|
5254
|
-
send({ status: "error", message: "No woff2 files available" });
|
|
5255
|
-
controller.close();
|
|
5256
|
-
return;
|
|
5257
|
-
}
|
|
5258
|
-
const fontMap = woff2Files.map((file) => {
|
|
5259
|
-
const baseName = path11.basename(file, ".woff2");
|
|
5260
|
-
const { weight, style } = parseFontMetadata(baseName);
|
|
5261
|
-
return {
|
|
5262
|
-
path: `${folderName}/${file}`,
|
|
5263
|
-
weight,
|
|
5264
|
-
style
|
|
5265
|
-
};
|
|
5266
|
-
});
|
|
5267
5291
|
const srcFontsPath = getWorkspacePath("src/fonts");
|
|
5268
5292
|
if (!existsSync(srcFontsPath)) {
|
|
5269
5293
|
mkdirSync(srcFontsPath, { recursive: true });
|