feat(core): Abstract design data sources behind per-asset-type protocols#75
feat(core): Abstract design data sources behind per-asset-type protocols#75alexey1312 merged 3 commits intomainfrom
Conversation
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.
Summary of ChangesHello, 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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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
Description
ColorsSource,ComponentsSource, andTypographySourceprotocols in ExFigCore to decouple the export pipeline from Figma-specific loadersDesignSourceKindenum (.figma, .penpot, .tokensFile, .tokensStudio, .sketchFile) for explicit source dispatchColorsSourceInputto usesourceKind+sourceConfig: any ColorsSourceConfiginstead of flat Figma/tokens-file fieldssourceKindfield (default.figma) toIconsSourceInput,ImagesSourceInput,TypographySourceInputFigmaColorsSource,TokensFileColorsSource,FigmaComponentsSource,FigmaTypographySourcefrom context implementations into dedicatedSource/directorySourceFactoryfor centralized source creation byDesignSourceKindSourceKindtypealias andsourceKindfield to PKL schemas (FrameSource,VariablesSource).figmasourceKindAdditional notes
DownloadColors,DownloadIcons,DownloadImages) and MCPexfig_downloadhandler are deferred — they use separate loader code paths not covered by this refactoringIconsExportContextImpl/ImagesExportContextImplretains directclientusage alongside injectedComponentsSourcesourceKinddefaults to.figma