Skip to content

feat(core): Abstract design data sources behind per-asset-type protocols#75

Merged
alexey1312 merged 3 commits intomainfrom
feature/design-source-abstraction
Mar 21, 2026
Merged

feat(core): Abstract design data sources behind per-asset-type protocols#75
alexey1312 merged 3 commits intomainfrom
feature/design-source-abstraction

Conversation

@alexey1312
Copy link
Collaborator

Description

  • Introduce ColorsSource, ComponentsSource, and TypographySource protocols in ExFigCore to decouple the export pipeline from Figma-specific loaders
  • Add DesignSourceKind enum (.figma, .penpot, .tokensFile, .tokensStudio, .sketchFile) for explicit source dispatch
  • Refactor ColorsSourceInput to use sourceKind + sourceConfig: any ColorsSourceConfig instead of flat Figma/tokens-file fields
  • Add sourceKind field (default .figma) to IconsSourceInput, ImagesSourceInput, TypographySourceInput
  • Extract FigmaColorsSource, TokensFileColorsSource, FigmaComponentsSource, FigmaTypographySource from context implementations into dedicated Source/ directory
  • Add SourceFactory for centralized source creation by DesignSourceKind
  • Refactor all 4 context implementations to accept injected source protocols via constructor
  • Update all Plugin*Export files to create sources via factory
  • Add SourceKind typealias and sourceKind field to PKL schemas (FrameSource, VariablesSource)
  • Add sourceKind resolution priority: explicit PKL value > auto-detect (tokensFile presence) > default .figma
  • Update entry bridge methods in all 4 platform modules to pass sourceKind

Additional notes

  • Download commands (DownloadColors, DownloadIcons, DownloadImages) and MCP exfig_download handler are deferred — they use separate loader code paths not covered by this refactoring
  • Granular cache path in IconsExportContextImpl/ImagesExportContextImpl retains direct client usage alongside injected ComponentsSource
  • Full backward compatibility: all existing PKL configs work without changes, sourceKind defaults to .figma
  • 1828 tests pass, lint clean, format clean

Introduce ColorsSource, ComponentsSource, and TypographySource protocols
in ExFigCore to decouple the export pipeline from Figma-specific loaders.
This lays the foundation for supporting alternative design tools (Penpot,
Sketch, Tokens Studio) without modifying the export infrastructure.

- Add DesignSourceKind enum and ColorsSourceConfig protocol pattern
- Refactor ColorsSourceInput to use sourceKind + sourceConfig
- Extract FigmaColorsSource, TokensFileColorsSource, FigmaComponentsSource,
  FigmaTypographySource from context implementations
- Add SourceFactory for centralized source dispatch
- Add sourceKind field to PKL schemas (FrameSource, VariablesSource)
- Update all context impls, plugin exports, and entry bridges
Sync 4 delta specs to main: design-source-protocol (new),
source-dispatch (new), configuration (updated),
tokens-file-source (updated). Archive completed change.
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant refactoring to abstract design data sources behind protocols, enhancing flexibility and maintainability. It decouples the export pipeline from Figma-specific loaders by introducing ColorsSource, ComponentsSource, and TypographySource protocols. A SourceFactory is added for centralized source creation, and existing context implementations are refactored to accept injected source protocols. This change maintains backward compatibility and ensures existing PKL configurations work without modification.

Highlights

  • Design Source Abstraction: Introduced protocols for different design sources (Figma, Tokens File, etc.) to decouple the export pipeline from specific loaders.
  • SourceFactory: Implemented a centralized factory for creating source instances based on DesignSourceKind.
  • Context Refactoring: Refactored export contexts to accept injected source protocols, promoting loose coupling and testability.
  • PKL Schema Updates: Added sourceKind to PKL schemas for FrameSource and VariablesSource, enabling explicit source dispatch.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and valuable abstraction layer for data sources, decoupling the export pipeline from Figma-specific loaders. The introduction of *Source protocols, a SourceFactory, and updates to the PKL schema are well-executed. However, there are some critical issues in the implementation of the plugin export subcommands where the new sources are instantiated. The new SourceFactory is not used, and Figma...Source implementations are hardcoded, which defeats the purpose of the abstraction. Additionally, a useful warning for users has been lost in the refactoring. My review includes detailed feedback on these points.

…ings

ColorsExportContextImpl now uses per-call SourceFactory dispatch instead of
injected colorsSource, enabling per-entry sourceKind in multi-source configs.
Fixes tokens-file colors export which was broken by hardcoded FigmaColorsSource.

- Remove FigmaColorsSource injection from all 4 PluginColorsExport methods
- Add ignoredModeNames to TokensFileColorsConfig for dark mode field warnings
- Make unsupportedSourceKind error asset-type-aware with correct recovery hints
- Add spinnerLabel to ColorsSourceInput for informative progress messages
- Add 16 tests: SourceKindBridging, explicit override, ignoredModeNames, errors
@alexey1312 alexey1312 merged commit 6f22b8b into main Mar 21, 2026
3 checks passed
@alexey1312 alexey1312 deleted the feature/design-source-abstraction branch March 21, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant