v2.0.0
๐ Gradiente v2.0
Major release introducing a pattern-driven Gradient DSL, a full ABI parsing pipeline, and a modular architecture for building and validating gradients.
โจ Highlights
๐ง Gradient DSL (Pattern System)
Gradiente now includes a custom Domain-Specific Language (DSL) for describing valid gradient input structures.
^[([config,color-stop,([color-hint,color-stop]|color-stop)]|color-stop),~([color-hint,color-stop]|color-stop)].With this DSL you can:
- define allowed input sequences
- validate gradient structures
- support custom gradient types (e.g. mesh, diamond, etc.)
- avoid hardcoded parsing rules
Gradients are no longer just parsed โ they are validated against a formal structure.
โ๏ธ ABI Layer (Gradient as Data)
Gradients are transformed into a normalized ABI:
{
functionName: 'linear-gradient',
isRepeating: false,
inputs: [
{ type: 'config', value: 'to left' },
{ type: 'color-stop', value: 'red 10%' },
{ type: 'color-hint', value: '50%' },
{ type: 'color-stop', value: 'blue 80%' },
]
}This enables:
- predictable processing
- renderer-agnostic workflows
- easier transformations and exports
๐ Modular Parsing Pipeline
Gradiente now uses a layered architecture:
-
Function extractor
โ findsgradient(...) -
Top-level input splitter
โ safely splits arguments (handles nested functions) -
Classifier
โ detects:configcolor-stopcolor-hint
-
Pattern validator (DSL)
โ validates structure using your DSL -
Matcher engine
โ executes the DSL against ABI inputs
๐งฉ Matcher Engine
A custom execution engine that:
-
walks through pattern tokens
-
matches against classified inputs
-
supports:
- sequences
[] - groups
() - alternatives
| - repetition
~
- sequences
This is effectively a mini pattern engine, purpose-built for gradients.
โก Performance
- ~100k inputs validated in ~18ms
- near-linear complexity
- safe repeat handling (no infinite loops)
๐งฑ Architecture
Gradiente is now structured as a set of independent modules:
extractOuterFunctionCallโ function parsingsplitTopLevelInputsโ safe argument splittingclassifyInputsโ ABI classificationpattern-validatorโ DSL validationmatchโ DSL execution engine
Each layer is isolated and reusable.
๐ Extensibility
You can now define custom gradient rules:
parseStringToAbi(value, '^[color-stop,~color-stop].');Example use cases:
- mesh gradients (no config)
- strict validation modes
- experimental gradient types
โ ๏ธ Breaking Changes
- Full rewrite of parsing logic
- Old parsing behavior is no longer supported
- Gradients are now validated strictly via DSL
๐ Example
parseStringToAbi(
'linear-gradient(to left, red 10%, 50%, blue 80%)'
);๐ฎ What's next
-
Gradient normalization layer
-
Rendering adapters:
- Canvas2D
- PixiJS
- Konva
- WebGL / WebGPU
-
Playground for DSL and gradients
๐ง Summary
Gradiente is no longer just a parser.
It is now a gradient engine with a validation DSL, designed for:
- visual editors
- rendering engines
- developer tooling