openfig-cli 0.3.11 → 0.3.12
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 +1 -1
- package/lib/core/fig-deck.mjs +19 -18
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/core/fig-deck.mjs
CHANGED
|
@@ -13,8 +13,8 @@ import { decodeBinarySchema, compileSchema, encodeBinarySchema } from 'kiwi-sche
|
|
|
13
13
|
import { decompress } from 'fzstd';
|
|
14
14
|
import { inflateRaw, deflateRaw } from 'pako';
|
|
15
15
|
import { ZstdCodec } from 'zstd-codec';
|
|
16
|
-
import
|
|
17
|
-
import { readFileSync, createWriteStream, existsSync, mkdtempSync } from 'fs';
|
|
16
|
+
import yazl from 'yazl';
|
|
17
|
+
import { readFileSync, createWriteStream, existsSync, mkdtempSync, readdirSync } from 'fs';
|
|
18
18
|
import { execSync } from 'child_process';
|
|
19
19
|
import { join, resolve } from 'path';
|
|
20
20
|
import { tmpdir } from 'os';
|
|
@@ -288,36 +288,37 @@ export class FigDeck {
|
|
|
288
288
|
const absOut = resolve(outPath);
|
|
289
289
|
|
|
290
290
|
return new Promise((resolveP, reject) => {
|
|
291
|
-
const
|
|
292
|
-
const archive = archiver('zip', { store: true });
|
|
293
|
-
|
|
294
|
-
archive.on('error', reject);
|
|
295
|
-
output.on('close', () => resolveP(archive.pointer()));
|
|
296
|
-
|
|
297
|
-
archive.pipe(output);
|
|
291
|
+
const zipfile = new yazl.ZipFile();
|
|
298
292
|
|
|
299
293
|
// canvas.fig
|
|
300
|
-
|
|
294
|
+
const figBytes = Buffer.from(figBuf);
|
|
295
|
+
zipfile.addBuffer(figBytes, 'canvas.fig');
|
|
301
296
|
|
|
302
297
|
// thumbnail.png
|
|
303
298
|
const thumb = opts.thumbnail || this.deckThumbnail;
|
|
304
|
-
if (thumb)
|
|
305
|
-
archive.append(Buffer.from(thumb), { name: 'thumbnail.png' });
|
|
306
|
-
}
|
|
299
|
+
if (thumb) zipfile.addBuffer(Buffer.from(thumb), 'thumbnail.png');
|
|
307
300
|
|
|
308
301
|
// meta.json
|
|
309
302
|
const meta = opts.meta || this.deckMeta;
|
|
310
|
-
if (meta)
|
|
311
|
-
archive.append(JSON.stringify(meta), { name: 'meta.json' });
|
|
312
|
-
}
|
|
303
|
+
if (meta) zipfile.addBuffer(Buffer.from(JSON.stringify(meta)), 'meta.json');
|
|
313
304
|
|
|
314
305
|
// images/
|
|
315
306
|
const imgDir = opts.imagesDir || this.imagesDir;
|
|
316
307
|
if (imgDir && existsSync(imgDir)) {
|
|
317
|
-
|
|
308
|
+
for (const entry of readdirSync(imgDir, { withFileTypes: true, recursive: true })) {
|
|
309
|
+
if (entry.isFile()) {
|
|
310
|
+
const fullPath = join(entry.parentPath ?? entry.path, entry.name);
|
|
311
|
+
const rel = fullPath.slice(imgDir.length + 1).replace(/\\/g, '/');
|
|
312
|
+
zipfile.addBuffer(readFileSync(fullPath), `images/${rel}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
318
315
|
}
|
|
319
316
|
|
|
320
|
-
|
|
317
|
+
zipfile.end();
|
|
318
|
+
const output = createWriteStream(absOut);
|
|
319
|
+
output.on('close', resolveP);
|
|
320
|
+
output.on('error', reject);
|
|
321
|
+
zipfile.outputStream.pipe(output);
|
|
321
322
|
});
|
|
322
323
|
}
|
|
323
324
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openfig-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "OpenFig — Open-source tools for parsing and rendering Figma design files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
47
47
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
48
|
-
"archiver": "^7.0.1",
|
|
49
48
|
"fzstd": "^0.1.1",
|
|
50
49
|
"kiwi-schema": "^0.5.0",
|
|
51
50
|
"pako": "^2.1.0",
|
|
52
51
|
"sharp": "^0.34.5",
|
|
53
52
|
"ssim.js": "^3.5.0",
|
|
53
|
+
"yazl": "^3.3.1",
|
|
54
54
|
"zstd-codec": "^0.1.5"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|