Documentation
¶
Index ¶
- Constants
- func PrintConflictSummary(conflicts []Conflict)
- type CSSParser
- type CSSVariablesFormatter
- type Change
- type ChangeType
- type ColorFormat
- type Conflict
- type ConflictResolution
- type ConflictResolutionStrategy
- type ConflictResolutionStrategyUpload
- type ConflictResolver
- type ConflictResolverConfig
- type ConflictType
- type DesignClient
- type ExtractionResult
- type Extractor
- type ExtractorOptions
- type Formatter
- type JSONFormatter
- type LESSParser
- type OutputFormat
- type ParseError
- type Parser
- type SCSSParser
- type SCSSVariablesFormatter
- type StyleDictionaryFormatter
- type SyncConfig
- type SyncDirection
- type SyncResult
- type SyncState
- type Syncer
- type TailwindFormatter
- type TemplateEngine
- type Token
- type TokenCategorizer
- type TokenCollection
- type TokenType
- type TokenWithMetadata
- type ValidationError
- type ValidationResult
- type Validator
- type WatchConfig
- type WatchEvent
- type Watcher
- type YAMLFormatter
Constants ¶
const CSSTemplate = `` /* 167-byte string literal not displayed */
CSSTemplate is the template for CSS variables generation
const JavaScriptTemplate = `` /* 193-byte string literal not displayed */
JavaScriptTemplate is the template for JavaScript constants generation
const SCSSTemplate = `` /* 147-byte string literal not displayed */
SCSSTemplate is the template for SCSS variables generation
const TailwindTemplate = `` /* 1029-byte string literal not displayed */
TailwindTemplate is the template for Tailwind config generation
const TypeScriptTemplate = `` /* 250-byte string literal not displayed */
TypeScriptTemplate is the template for TypeScript constants generation
Variables ¶
This section is empty.
Functions ¶
func PrintConflictSummary ¶
func PrintConflictSummary(conflicts []Conflict)
PrintConflictSummary prints a summary of conflicts and their resolutions.
Types ¶
type CSSParser ¶
type CSSParser struct {
// contains filtered or unexported fields
}
CSSParser parses CSS files to extract design tokens.
type CSSVariablesFormatter ¶
type CSSVariablesFormatter struct {
Prefix string
}
CSSVariablesFormatter formats tokens as CSS custom properties.
func NewCSSVariablesFormatter ¶
func NewCSSVariablesFormatter(prefix string) *CSSVariablesFormatter
NewCSSVariablesFormatter creates a new CSS variables formatter.
type Change ¶
type Change struct {
// Type is the type of change.
Type ChangeType
// Token is the token that changed.
Token *Token
// OldToken is the previous version of the token (for updates).
OldToken *Token
// Timestamp is when the change was detected.
Timestamp time.Time
}
Change represents a change detected in tokens.
type ChangeType ¶
type ChangeType string
ChangeType represents the type of change detected.
const ( // ChangeTypeCreate indicates a token was created. ChangeTypeCreate ChangeType = "create" // ChangeTypeUpdate indicates a token was updated. ChangeTypeUpdate ChangeType = "update" // ChangeTypeDelete indicates a token was deleted. ChangeTypeDelete ChangeType = "delete" )
type ColorFormat ¶
type ColorFormat string
ColorFormat represents the format of a color value.
const ( ColorFormatHex ColorFormat = "hex" ColorFormatRGB ColorFormat = "rgb" ColorFormatRGBA ColorFormat = "rgba" ColorFormatHSL ColorFormat = "hsl" ColorFormatHSLA ColorFormat = "hsla" )
type Conflict ¶
type Conflict struct {
// TokenName is the name of the conflicting token.
TokenName string
// LocalToken is the local version of the token.
LocalToken *Token
// RemoteToken is the remote version of the token.
RemoteToken *Token
// ConflictType is the type of conflict.
ConflictType ConflictType
// Resolution is the chosen resolution for this conflict.
Resolution *ConflictResolution
}
Conflict represents a conflict between local and remote tokens.
type ConflictResolution ¶
type ConflictResolution struct {
// Strategy is the strategy used to resolve the conflict.
Strategy ConflictResolutionStrategy
// SelectedToken is the token that was selected as the resolution.
SelectedToken *Token
// Reason is the reason for the resolution.
Reason string
}
ConflictResolution represents the resolution of a conflict.
type ConflictResolutionStrategy ¶
type ConflictResolutionStrategy string
ConflictResolutionStrategy represents how to handle conflicts.
const ( // ConflictResolutionLocal prefers local changes over remote. ConflictResolutionLocal ConflictResolutionStrategy = "local" // ConflictResolutionRemote prefers remote changes over remote. ConflictResolutionRemote ConflictResolutionStrategy = "remote" // ConflictResolutionNewest prefers the newest changes based on timestamp. ConflictResolutionNewest ConflictResolutionStrategy = "newest" // ConflictResolutionPrompt prompts the user to resolve conflicts. ConflictResolutionPrompt ConflictResolutionStrategy = "prompt" // ConflictResolutionMerge attempts to merge changes. ConflictResolutionMerge ConflictResolutionStrategy = "merge" )
type ConflictResolutionStrategyUpload ¶
type ConflictResolutionStrategyUpload string
ConflictResolutionStrategy defines how to handle conflicting tokens during upload. Renamed from ConflictResolution to avoid conflict with sync_types.go
const ( // ConflictOverwrite replaces existing tokens with new values ConflictOverwrite ConflictResolutionStrategyUpload = "overwrite" // ConflictMerge merges new tokens with existing, preferring new values ConflictMerge ConflictResolutionStrategyUpload = "merge" // ConflictSkip skips conflicting tokens and keeps existing values ConflictSkip ConflictResolutionStrategyUpload = "skip" )
type ConflictResolver ¶
type ConflictResolver struct {
// contains filtered or unexported fields
}
ConflictResolver handles conflict resolution during synchronization.
func NewConflictResolver ¶
func NewConflictResolver(config ConflictResolverConfig) *ConflictResolver
NewConflictResolver creates a new conflict resolver.
func (*ConflictResolver) Resolve ¶
func (r *ConflictResolver) Resolve(conflict Conflict) ConflictResolution
Resolve resolves a conflict based on the configured strategy.
func (*ConflictResolver) ResolveAll ¶
func (r *ConflictResolver) ResolveAll(conflicts []Conflict) []ConflictResolution
ResolveAll resolves multiple conflicts in batch.
type ConflictResolverConfig ¶
type ConflictResolverConfig struct {
// Strategy is the default strategy for resolving conflicts.
Strategy ConflictResolutionStrategy
// Interactive enables interactive prompts for conflict resolution.
Interactive bool
}
ConflictResolverConfig configures the conflict resolver.
type ConflictType ¶
type ConflictType string
ConflictType represents the type of conflict.
const ( // ConflictTypeBothModified indicates both local and remote were modified. ConflictTypeBothModified ConflictType = "both_modified" // ConflictTypeLocalDeleted indicates local was deleted but remote was modified. ConflictTypeLocalDeleted ConflictType = "local_deleted" // ConflictTypeRemoteDeleted indicates remote was deleted but local was modified. ConflictTypeRemoteDeleted ConflictType = "remote_deleted" // ConflictTypeTypeChange indicates the token type changed. ConflictTypeTypeChange ConflictType = "type_change" )
type DesignClient ¶
type DesignClient interface {
// GetTokens retrieves all design tokens for a project.
GetTokens(ctx context.Context, projectID string) ([]Token, error)
// UploadTokens uploads design tokens to the remote project.
UploadTokens(ctx context.Context, projectID string, tokens []Token) error
// DeleteToken deletes a design token from the remote project.
DeleteToken(ctx context.Context, projectID string, tokenName string) error
}
DesignClient defines the interface for interacting with the design API.
type ExtractionResult ¶
ExtractionResult represents the result of token extraction.
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor extracts design tokens from CSS/SCSS/LESS files.
func NewExtractor ¶
func NewExtractor(opts *ExtractorOptions) *Extractor
NewExtractor creates a new design token extractor.
func (*Extractor) ExtractFromFile ¶
func (e *Extractor) ExtractFromFile(filePath string) (*ExtractionResult, error)
ExtractFromFile extracts design tokens from a file.
type ExtractorOptions ¶
ExtractorOptions configures the token extractor.
type Formatter ¶
Formatter formats design tokens into various output formats.
func GetFormatter ¶
func GetFormatter(format OutputFormat, options map[string]interface{}) (Formatter, error)
GetFormatter returns the appropriate formatter based on the output format.
type JSONFormatter ¶
type JSONFormatter struct {
Pretty bool
}
JSONFormatter formats tokens as JSON.
func NewJSONFormatter ¶
func NewJSONFormatter(pretty bool) *JSONFormatter
NewJSONFormatter creates a new JSON formatter.
type LESSParser ¶
type LESSParser struct {
// contains filtered or unexported fields
}
LESSParser parses LESS files to extract design tokens.
func (*LESSParser) Parse ¶
func (p *LESSParser) Parse(reader io.Reader) (*ExtractionResult, error)
Parse parses a LESS file and extracts design tokens.
type OutputFormat ¶
type OutputFormat string
OutputFormat represents the format for token output.
const ( OutputFormatJSON OutputFormat = "json" OutputFormatYAML OutputFormat = "yaml" OutputFormatTailwind OutputFormat = "tailwind" )
type ParseError ¶
ParseError represents an error that occurred during parsing.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Parser ¶
type Parser interface {
Parse(reader io.Reader) (*ExtractionResult, error)
}
Parser is an interface for parsing different CSS-like formats.
type SCSSParser ¶
type SCSSParser struct {
// contains filtered or unexported fields
}
SCSSParser parses SCSS files to extract design tokens.
func (*SCSSParser) Parse ¶
func (p *SCSSParser) Parse(reader io.Reader) (*ExtractionResult, error)
Parse parses an SCSS file and extracts design tokens.
type SCSSVariablesFormatter ¶
type SCSSVariablesFormatter struct{}
SCSSVariablesFormatter formats tokens as SCSS variables.
func NewSCSSVariablesFormatter ¶
func NewSCSSVariablesFormatter() *SCSSVariablesFormatter
NewSCSSVariablesFormatter creates a new SCSS variables formatter.
type StyleDictionaryFormatter ¶
type StyleDictionaryFormatter struct {
Pretty bool
}
StyleDictionaryFormatter formats tokens in Style Dictionary format.
func NewStyleDictionaryFormatter ¶
func NewStyleDictionaryFormatter(pretty bool) *StyleDictionaryFormatter
NewStyleDictionaryFormatter creates a new Style Dictionary formatter.
type SyncConfig ¶
type SyncConfig struct {
// ProjectID is the ID of the project to sync.
ProjectID string
// Direction is the direction of synchronization.
Direction SyncDirection
// WatchMode enables continuous watching for changes.
WatchMode bool
// WatchInterval is the interval for checking changes in watch mode.
WatchInterval time.Duration
// LocalPath is the local file path for tokens.
LocalPath string
// ConflictResolution is the strategy for resolving conflicts.
ConflictResolution ConflictResolutionStrategy
// DryRun performs a dry run without making actual changes.
DryRun bool
// Verbose enables verbose logging.
Verbose bool
}
SyncConfig represents the configuration for synchronization.
type SyncDirection ¶
type SyncDirection string
SyncDirection represents the direction of synchronization.
const ( // SyncDirectionPull pulls tokens from remote to local. SyncDirectionPull SyncDirection = "pull" // SyncDirectionPush pushes tokens from local to remote. SyncDirectionPush SyncDirection = "push" // SyncDirectionBidirectional performs bidirectional sync. SyncDirectionBidirectional SyncDirection = "bidirectional" )
type SyncResult ¶
type SyncResult struct {
// Added is the number of tokens added.
Added int
// Updated is the number of tokens updated.
Updated int
// Deleted is the number of tokens deleted.
Deleted int
// Conflicts is the list of conflicts encountered.
Conflicts []Conflict
// Errors is the list of errors encountered.
Errors []error
// Duration is the time taken for the sync operation.
Duration time.Duration
// DryRun indicates if this was a dry run.
DryRun bool
}
SyncResult represents the result of a synchronization operation.
type SyncState ¶
type SyncState struct {
// ProjectID is the project being synced.
ProjectID string
// LastSyncedAt is the last successful sync timestamp.
LastSyncedAt time.Time
// LocalTokens is the snapshot of local tokens.
LocalTokens map[string]*TokenWithMetadata
// RemoteTokens is the snapshot of remote tokens.
RemoteTokens map[string]*TokenWithMetadata
}
SyncState represents the state of a synchronization session.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer handles bidirectional design token synchronization.
func NewSyncer ¶
func NewSyncer(client DesignClient, config SyncConfig) *Syncer
NewSyncer creates a new design token syncer.
type TailwindFormatter ¶
type TailwindFormatter struct {
IncludeComments bool
}
TailwindFormatter formats tokens as a Tailwind CSS configuration.
func NewTailwindFormatter ¶
func NewTailwindFormatter(includeComments bool) *TailwindFormatter
NewTailwindFormatter creates a new Tailwind formatter.
type TemplateEngine ¶
type TemplateEngine struct {
// contains filtered or unexported fields
}
TemplateEngine provides template-based code generation functionality
func NewTemplateEngine ¶
func NewTemplateEngine() *TemplateEngine
NewTemplateEngine creates a new template engine with built-in functions
func (*TemplateEngine) Execute ¶
func (te *TemplateEngine) Execute(name string, data interface{}) (string, error)
Execute executes a registered template with the given data
func (*TemplateEngine) ExecuteString ¶
func (te *TemplateEngine) ExecuteString(templateStr string, data interface{}) (string, error)
ExecuteString executes an inline template string with the given data
func (*TemplateEngine) RegisterTemplate ¶
func (te *TemplateEngine) RegisterTemplate(name string, content string) error
RegisterTemplate registers a new template with the engine
type Token ¶
type Token struct {
Name string `json:"name" yaml:"name"`
Type TokenType `json:"type" yaml:"type"`
Value string `json:"value" yaml:"value"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Category string `json:"category,omitempty" yaml:"category,omitempty"`
Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}
Token represents a single design token extracted from CSS/SCSS/LESS.
func (*Token) ComputeHash ¶
ComputeHash computes a hash of the token for change detection.
type TokenCategorizer ¶
type TokenCategorizer struct {
// contains filtered or unexported fields
}
TokenCategorizer categorizes tokens based on their properties.
func NewTokenCategorizer ¶
func NewTokenCategorizer() *TokenCategorizer
NewTokenCategorizer creates a new token categorizer.
func (*TokenCategorizer) Categorize ¶
func (c *TokenCategorizer) Categorize(token *Token)
Categorize assigns a category to a token based on its name and type.
type TokenCollection ¶
type TokenCollection struct {
Tokens []Token `json:"tokens" yaml:"tokens"`
Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}
TokenCollection represents a collection of design tokens organized by type.
type TokenType ¶
type TokenType string
TokenType represents the category of a design token.
const ( // TokenTypeColor represents color tokens (hex, rgb, hsl) TokenTypeColor TokenType = "color" // TokenTypeTypography represents typography-related tokens TokenTypeTypography TokenType = "typography" // TokenTypeSpacing represents spacing tokens (margin, padding) TokenTypeSpacing TokenType = "spacing" // TokenTypeShadow represents shadow tokens TokenTypeShadow TokenType = "shadow" // TokenTypeBorderRadius represents border-radius tokens TokenTypeBorderRadius TokenType = "border-radius" )
type TokenWithMetadata ¶
type TokenWithMetadata struct {
Token
// LastSyncedAt is the timestamp when this token was last synced.
LastSyncedAt time.Time `json:"last_synced_at,omitempty"`
// Hash is the hash of the token for change detection.
Hash string `json:"hash"`
// Version is the version number for optimistic locking.
Version int `json:"version"`
}
TokenWithMetadata extends Token with sync metadata.
type ValidationError ¶
ValidationError represents a token validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Errors []*ValidationError
}
ValidationResult contains the results of token validation.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator provides design token validation functionality.
func (*Validator) Validate ¶
func (v *Validator) Validate(token *Token) *ValidationResult
Validate validates a single design token.
func (*Validator) ValidateBatch ¶
func (v *Validator) ValidateBatch(tokens []*Token) *ValidationResult
ValidateBatch validates a batch of design tokens.
type WatchConfig ¶
type WatchConfig struct {
// Paths to watch for changes.
Paths []string
// Debounce duration to prevent rapid re-syncs.
DebounceDuration time.Duration
// SyncOnStart triggers an initial sync when watch mode starts.
SyncOnStart bool
// MaxRetries for sync operations.
MaxRetries int
// RetryDelay between sync retries.
RetryDelay time.Duration
}
WatchConfig configures the file watcher.
type WatchEvent ¶
type WatchEvent struct {
// Path is the path of the file that changed.
Path string
// Type is the type of change.
Type ChangeType
// Timestamp is when the change was detected.
Timestamp time.Time
}
WatchEvent represents a file system change event.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors file system changes and triggers synchronization.
func NewWatcher ¶
func NewWatcher(syncer *Syncer, config WatchConfig) (*Watcher, error)
NewWatcher creates a new file system watcher.
type YAMLFormatter ¶
type YAMLFormatter struct{}
YAMLFormatter formats tokens as YAML.
func NewYAMLFormatter ¶
func NewYAMLFormatter() *YAMLFormatter
NewYAMLFormatter creates a new YAML formatter.