openfig-cli 0.3.24 → 0.3.25

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.
@@ -20,6 +20,7 @@ import { join, resolve } from 'path';
20
20
  import { tmpdir } from 'os';
21
21
  import { nid } from './node-helpers.mjs';
22
22
  import { deepClone } from './deep-clone.mjs';
23
+ import { hashToHex } from './image-helpers.mjs';
23
24
 
24
25
  export class FigDeck {
25
26
  constructor() {
@@ -420,15 +421,28 @@ export class FigDeck {
420
421
  mkdirSync(this.imagesDir, { recursive: true });
421
422
  }
422
423
 
424
+ const copyImagePaint = (paint) => {
425
+ if (!paint) return;
426
+ if (paint.type === 'IMAGE' || paint.image) {
427
+ const name = paint.image?.name || (paint.image?.hash?.length ? hashToHex(paint.image.hash) : null);
428
+ if (name) this._copyImageAsset(sourceDeck.imagesDir, name);
429
+ }
430
+ if (paint.imageThumbnail) {
431
+ const tName = paint.imageThumbnail.name || (paint.imageThumbnail.hash?.length ? hashToHex(paint.imageThumbnail.hash) : null);
432
+ if (tName) this._copyImageAsset(sourceDeck.imagesDir, tName);
433
+ }
434
+ };
435
+
423
436
  for (const clone of clonedNodes) {
424
- // Copy IMAGE fills
437
+ // Copy IMAGE fills from node fillPaints
425
438
  if (clone.fillPaints) {
426
- for (const paint of clone.fillPaints) {
427
- if (paint.type === 'IMAGE' && paint.image?.name) {
428
- this._copyImageAsset(sourceDeck.imagesDir, paint.image.name);
429
- }
430
- if (paint.imageThumbnail?.name) {
431
- this._copyImageAsset(sourceDeck.imagesDir, paint.imageThumbnail.name);
439
+ for (const paint of clone.fillPaints) copyImagePaint(paint);
440
+ }
441
+ // Copy images from symbolOverrides (INSTANCE nodes)
442
+ if (clone.symbolData?.symbolOverrides) {
443
+ for (const ov of clone.symbolData.symbolOverrides) {
444
+ if (ov.fillPaints) {
445
+ for (const paint of ov.fillPaints) copyImagePaint(paint);
432
446
  }
433
447
  }
434
448
  }
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": "0.2",
3
3
  "name": "openfig",
4
- "version": "0.3.24",
4
+ "version": "0.3.25",
5
5
  "description": "Open-source tools for Figma file parsing and rendering",
6
6
  "author": {
7
7
  "name": "OpenFig Contributors"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfig-cli",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "description": "OpenFig — Open-source tools for Figma file parsing and rendering",
5
5
  "type": "module",
6
6
  "bin": {